PowerShell Desired State Configuration failed to register MOF file

Welcome Forums DSC (Desired State Configuration) PowerShell Desired State Configuration failed to register MOF file

This topic contains 4 replies, has 2 voices, and was last updated by

4 years, 8 months ago.

  • Author
  • #16063

    Points: 0
    Rank: Member

    I'm hoping someone can help me with this as my searching for an answer has turned up nothing.
    I'm writing a custom DSC resource for managing XML files for configuring an internal application. I've created two resources which I've deployed to a test server with WMF 4.0. When I push a configuration to the server I get the following error.

    PowerShell Desired State Configuration failed to register MOF file cXML using Mofcomp.exe during discovery of
    C:\Program Files\WindowsPowerShell\Modules\cXML\DscResources\cXMLAttribute\cXMLAttribute.schema.mof resource Provider.
    Check the MOF file and try again.
    + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName : TESTN4APP01

    The resource is in the correct module path and I have followed the folder and file format and even compared it to the resources Microsoft has released in their waves and I can't see where I've gone wrong. I've attached the resource MOF file for the resource that is causing this error.

  • #16066

    Points: 0
    Rank: Member

    Since I can't upload a MOF file, here are the contents.

    [ClassVersion(""), FriendlyName("cXMLAttribute")]
    class cXMLAttribute : OMI_BaseResource
    [Key] String XPath;
    [Key, EmbeddedInstance("MSFT_KeyValuePair")] String XAttributes;
    [Write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
    [Key] String File;
    [Write] Boolean NotMatch;


  • #16067

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    We usually ask that folks rename files to .TXT, but pasting a short one is fine.

    I think you're missing some of the schema bits. I'd suggest using the DSC Resource Kit's designer module. It'll produce the correct schema MOF. You can probably try running Mofcomp.exe against it directly, but the ResourceDesigner is the best way to go. This is top-of-my-head; I don't have access to a PowerShell machine right at the moment.

  • #16072

    Points: 0
    Rank: Member

    Yes I used the resource designer toolkit to generate the MOF orginally and I just recreated it to test that I hadn't made some sort of manual change at some point.

    I ran the Test-DSCSchema cmdlet on the mof schema and it actually threw an error.
    "Test-SchemaProperty : For property XAttributes, the attribute Read can not be used with any other property."

    If I remove the "EmbeddedInstance("MSFT_KeyValuePair")" from the XAttributes property the test passes.

  • #16077

    Points: 0
    Rank: Member

    Actually I think I have resolved it. The "Key" attribute must be the only attribute in the definition of that property. It seems if you define the type as "Hashtable" it creates a second attribute in the schema MOF. To get around it I have changes the property to a string variable and then I'm doing a conversion to a hashtable in code. Ugly but I can't find a better way around it.

The topic ‘PowerShell Desired State Configuration failed to register MOF file’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort