Naming

There are two DSC resource names to keep track of: the CIM class name (sometimes referred to as the fully qualified name) and the friendly name. The CIM class name is the name that DSC uses internally to refer to a DSC resource, and the friendly name is typically a shorter and easier-to-read version for a human.

You have to be careful in specifying these names, as your choice of which one to include determines how your users ask for your DSC resource. If you specify the same name for both, then a user uses that name when they ask for the DSC resource to be imported. If you specify the CIM class name but not the friendly name, then the user has to specify the CIM class name. If you specify the friendly name, then the user must use that to import your DSC resource and cannot use the CIM class name. If all this sounds confusing, do like the author does and keep it simple by setting both names the same when authoring DSC resources.

We can simplify naming the DSC resource in the MOF example we used earlier, as shown here:

[ClassVersion("1.0.0"), FriendlyName("InstallFoo")]
class InstallFoo: OMI_BaseResource
{
[Key] string Name;
[Required] string PhysicalPath;
[write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure;
};

Why the complicated naming? It was explained that these different names account for situations where DSC resources are named the same and allow the user to specify which ones to load and use. As we will see in the class-based DSC resource section, this concept has been simplified greatly and is easier to use.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset