The errors you get back from the PowerShell DSC extension in Azure can be frustratingly terse. Here’s a way to troubleshoot and try out PowerShell DSC changes without having to deploy the extension over and over again. After the extension fails, RDP to the machine and go through these steps to troubleshoot on the VM you just spun up:
- Open the PowerShell DSC configuration file that was delivered by the Azure DSC extension in the PowerShell ISE, e.g. C:\Packages\Plugins\Microsoft.Powershell.DSC\22.214.171.124\DSCWork\PowerShellDSC.0\PowerShellDSC.ps1
- Change your ISE location to a known folder, e.g. “cd C:\temp”
- Save the file as localhost.ps1 into that folder, e.g. C:\temp\localhost.ps1
- Change “Node $nodeName” to be “Node localhost”
- At the bottom of the localhost.ps1 file, execute the configuration by calling the configuration, e.g. “Main”
- Run the script within the PowerShell ISE by hitting the play button; this should create a localhost.mof file under a folder of the same name of your configuration, e.g. C:\temp\Main
- Now you are set to troubleshoot the DSC resource with the Start-DscConfiguration cmdlet, e.g. “Start-DscConfiguration -Path .\Main -ComputerName localhost -Wait -Force -Verbose”
If you need additional DSC modules, you will need to install them to your module path (usually C:\Program Files\WindowsPowerShell\Modules) before you execute the configuration.
Hope this helps!