Nice, our own DSC forum, very, very good idea 🙂
From time to time I find my self needing to "run" an configuration that requires network access. I had this great idea to use register-pssessionconfiguration on the node and use the runascredential parameter for the cmdlet. Took me about 10 minutes to create the custom DSC resource, however that left me hanging in a catch 22 since the register command need to restart the winrm service (which I am using to push the configuration). I tried launching a new powershell session (with a new PID) to restart the winRM service from my custom DSC resource that (restart-service winrm -force), however that resulted in winrm service status Stop(pending). If i terminate the Svchost.exe process manually, the configuration is unable to continue (see error below).
WARNING: [S002]: [[FPsessionProxy]sccmProxy] Changes made by Register-PSSessionConfiguration cannot take effect until the WinRM service is restarted.
VERBOSE: Operation 'Invoke CimMethod' complete.
Please be gentle
You're not necessarily barking up a wrong tree.
There's probably a couple of ways to tackle this.
One that comes to mind would be to create a Scheduled Task that, some time in the future, restarts the WinRM service. That way your session can be "done."
But, have you looked at DSC Resource Kit Wave 3? There's a Microsoft resource that does this. See http://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d – it's the xPSSessionConfiguration resource, in the xPSDesiredStateConfiguration resource module.
BTW, hope you're planning to share that resource, if it does something unique! http://GitHub.com/powershellorg/DSC would be a good spot.
CURSES 🙂 completely missed that one from wave 3, thank you Don. Yes, I also thought about doing it with a scheduled task. Problem is that this is one of the first steps in the configuration. I could build an script on top that applies two DSC, however it is not very hot.
The xPSSessionConfiguration uses the '$global:DscMachineStatus = 1' to solve the catch 22, which is just a "computer restart required" before the rest of the configuration can be applied.
Regarding my resource. It is just something I wiped up in like 10 minutes, however it looks quite similar to the xPSSessionConfiguration resource. I used a different approach since my goal was to use PSSC files (we have the file resource you know). If you feel that is unique enough I can post it to GIT. I have attached the resource to this post.
Sorry, upload failed.
You must be logged in to reply to this topic.