DSC Cannot import PSDesiredStateConfiguration module

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Matt McElreath Matt McElreath 1 year, 7 months ago.

  • Author
    Posts
  • #30507
    Profile photo of Matt McElreath
    Matt McElreath
    Participant

    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
    PSDesiredStateConfiguration'.
    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.

  • #30509
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Have you installed the rollup hot fix for WMF4?

  • #30512
    Profile photo of Matt McElreath
    Matt McElreath
    Participant

    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.

  • #30518
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.

  • #30572
    Profile photo of Matt McElreath
    Matt McElreath
    Participant

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

You must be logged in to reply to this topic.