Windows Powershell Desired State Configuration (DSC) allows you to build custom resources to implement new functionality. When creating my first custom resource I stumbled across a few gotchas in the TechNet documentation. After using the TechNet example MOF Schema I hit a few errors. My assumption is this is due to changes from the preview version to the actual release version.
[version("1.0.0"), FriendlyName("Website")] class Demo_IISWebsite : MSFT_BaseResourceConfiguration { [Key] string Name; [write] string PhysicalPath; [write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; [write,ValueMap{"Started","Stopped"},Values{"Started", "Stopped"}] string State; [write,ValueMap{"http", "https"},Values{"http", "https"}] string Protocol[]; [write] string BindingInfo[]; [write] string ApplicationPool; [read] string ID; };
The first error occurred when generating the MOF files.
Fix: I opened the schema files that were installed, they inherited from “OMI_BaseResource” not “MSFT_BaseResourceConfiguration”
The second error was rather cryptic when trying to apply the MOF to the machine. ClassVersion Qualifier not found.
Fix: As with the first error, the documentation refers to a class attribute called “Version“, but it should be “ClassVersion” instead.
Working Schema
[ClassVersion("1.0.0"), FriendlyName("Website")] class Demo_IISWebsite : OMI_BaseResource { [Key] string Name; [write] string PhysicalPath; [write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; [write,ValueMap{"Started","Stopped"},Values{"Started", "Stopped"}] string State; [write,ValueMap{"http", "https"},Values{"http", "https"}] string Protocol[]; [write] string BindingInfo[]; [write] string ApplicationPool; [read] string ID; };