Author Posts

April 11, 2016 at 4:23 pm

I'm trying to get a first DSC config working and while I can get it to run cleanly and create an output directory. I don't get any MOF files.

I have a pull server setup, etc... and all that seems to be okay. My config script is just using a "File" source to pull in some files. I'm using "ConfigurationNames" in my LCMs. So, if the LCM pulls this file then I want it to apply. However, that's step 2 🙂

PS v5 is used.

My script looks like this:

##define nodes
$ConfigData = 
AllNodes = 
        #applies to all nodes
        NodeName = "*";

        #install files to
        InstallDest = "C:\\Program Files\Zabbix\\";


#define some variable(s) that are global to the config
NonNodeData = 
    #resource location - Zabbix EXE files (copy all .exe files)
    InstallFiles = "\\\\networkfilepath\\Zabbix\Agent\\3.0.0\win64\\";


Configuration Install_Zabbix_Agent
#load DSC resources  (Get-DscResource shows all available Modules and names)
#Import-DscResource -ModuleName PSDesiredStateConfiguration -Name Script;

#all nodes using this DSC
Node $AllNodes.NodeName

    #file resource
    File CreateZabbixDir

        Ensure = "Present";
        Type = "Directory";
        CheckSum = "SHA-1";
        SourcePath = $ConfigurationData.NonNodeData.InstallFiles;
        DestinationPath = $Node.InstallDest;


#call the config

I run the .ps1 and I don't get any MOF files. Just a empty directory. No errors.

April 11, 2016 at 8:16 pm

In the $ConfigData section, you're missing a node with the real name. To create a mof file you must supply a node name, be it local host or actual server name.

Stating NodeName="*" only means that everything that follows will be settings available for all the rest of the nodes. Else, logically running your script will create an infinite number of mof files 🙂

April 12, 2016 at 8:44 am

Thanks. I thought it would just create a Install_Zabbix_Agent.mof .

So, I will drop the "ConfigData" section as I want a MOF file that I will apply via ConfigurationNames and the LCM config will decide which MOF(s) to pull.

This then creates the single MOF file in question.

April 12, 2016 at 11:10 am

The mof file will always follow the nodename. you either supply the nodename via the $ConfigData or as a parameter to the command.

When you want to use it in conjunction with ConfigurationNames, use localhost as the node name, it will create a localhost.mof, you then rename it to what ever you want to match the value you placed in the ConfigurationNames in the LCM script