DSC Cannot import PSDesiredStateConfiguration module

We are having an issue setting up a Windows 2008 R2 server running PowerShell 4.0 with DSC. It looks like an issue with the PSDesiredStateConfiguration module failing to load. If I try to run any of the DSC cmlets, I get an error that the module cannot be loaded:

PS C:> Get-DscLocalConfigurationManager
Get-DscLocalConfigurationManager : The ‘Get-DscLocalConfigurationManager’ command was found in the module
‘PSDesiredStateConfiguration’, but the module could not be loaded. For more information, run ‘Import-Module
At line:1 char:1

  • Get-DscLocalConfigurationManager
  •   + CategoryInfo          : ObjectNotFound: (Get-DscLocalConfigurationManager:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

And if I try to manually import the module, I get the following error:

PS C:> Import-Module PSDesiredStateConfiguration
Import-Module : Cannot process Cmdlet Definition XML for the following file:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Get-DSCConfiguration.cdxml. The type
initializer for ‘Microsoft.PowerShell.Cmdletization.ScriptWriter’ threw an exception.
At line:1 char:1

  • Import-Module PSDesiredStateConfiguration
  •   + CategoryInfo          : NotSpecified: (:) [Import-Module], XmlException
      + FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.PowerShell.Commands.ImportModuleCommand

Has anyone run into this before, or know how to resolve it? We already tried re-installing WMF 4.0 and that didn’t work.

Have you installed the rollup hot fix for WMF4?

I don’t believe so. I’ll have to check. Where would I find that. I did a quick search but couldn’t find it.

It’s perhaps easiest to make sure the machine is completely patched ;). I’m not in a good position to look it up right now, but I’ll try to later on this evening.

Something must have been hosed in .NET. Uninstalling WMF 4, then uninstalling .NET and re-installing both seems to have fixed the issue.