PowerShell 4.0: Obscure DSC Errors

WS-Management Error

While playing around with PowerShell’s Desired State Configuration (DSC) feature this evening, I discovered a rather odd error message. I was developing a custom DSC resource, and attempting to use it in a Configuration block. When attempting to call Start-DscConfiguration, the error I received was:

DSC Error - Unrecognized Argument
DSC Error – Unrecognized Argument

The WS-Management service cannot process the request. The object contains an
unrecognized argument: “ConfigurationData”. Verify that the spelling of the
argument name is correct.
+ CategoryInfo : ProtocolError: (root/Microsoft/…gurationManager:St
ring) [], CimException
+ FullyQualifiedErrorId : HRESULT 0x80338041
+ PSComputerName : client01

While it doesn’t seem very clear, it seems that this error crops up if you’re running PowerShell Integrated Scripting Editor (ISE) as a non-administrator. Make sure that you launch your PowerShell host, whichever application that might be, as Administrator, when you call Start-DscConfiguration.

Access Denied

Another somewhat similar situation is when you’re running PowerShell ISE as non-administrator, you’ll get a much more friendly error message that indicates access is denied.DSC Error - Access Denied

The WS-Management service cannot process the request. The WMI service returned an ‘access denied’ error.
+ CategoryInfo : PermissionDenied: (root/Microsoft/…gurationManager
:String) [], CimException
+ FullyQualifiedErrorId : HRESULT 0x80338104
+ PSComputerName : client01

Get-TargetResource Error

After launching PowerShell ISE as Administrator, to resolve the two earlier DSC error messages, I came across another error. This one was fairly self-explanatory, but kinda hard to figure out the root cause of. I came across a post that suggested it was due to a problem with the new-line characters in Git. Coincidentally, I had my custom DSC resource in a Git repository, so it is quite possible that this is true. However, I couldn’t seem to fix my module manifest to make PowerShell happy, so instead I simply removed the module manifest file (.psd1) for the time being. The error message was:

Failed to get exported command Get-TargetResource from module ConfigMgr_Application. Please check the module definition.
+ CategoryInfo : InvalidOperation: (root/Microsoft/…gurationManager:String) [], CimException
+ FullyQualifiedErrorId : GetTargetResourceCommandNotFound
+ PSComputerName : client01

Could Not Get Module

Yet another error message I came across has pretty sparse information about it, but was successfully resolved by rebooting the Windows operating system on the problematic machine. In this case, it was a vanilla Windows 8.1 client (virtual machine) running PowerShell 4.0. It’s crazy that rebooting a system can resolve transient error messages these days, but … it is what it is, I guess. Here is Jacob Benson’s blog, which mentions the error.DSC Error - Could not get module

Could not get the module with the following name: ConfigMgr_Application. Check if the module exists under PSModulePath.