Executing configurations for local target nodes

Now that we have the MOF file compiled, we can apply it to our local computer using Start-DscConfiguration. We will use the Verbose, Wait, and Force parameters to indicate that we want it to execute interactively and output verbose information to our shell. We use Force to tell DSC to apply the MOF file regardless of the current state of the target node (whether it has a pending MOF file or not):

[BOX1 PS] > Start-DscConfiguration -Path C:vagrantSetupAllTheThings -Verbose -Wait -Force
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' =
    SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' =
    root/Microsoft/Windows/DesiredStateConfiguration'.
    VERBOSE: An LCM method call arrived from computer BOX1 with user sid
    S-1-5-21-1953236517-242735908-2433092285-500.
VERBOSE: [BOX1]: LCM:  [ Start  Set      ]
VERBOSE: [BOX1]: LCM:  [ Start  Resource ]  [[File]CreateaFile]
VERBOSE: [BOX1]: LCM:  [ Start  Test     ]  [[File]CreateaFile]
VERBOSE: [BOX1]:                            [[File]CreateaFile] The system cannot find the file specified.
VERBOSE: [BOX1]:                            [[File]CreateaFile] The related file/directory is: c:	est.txt.
VERBOSE: [BOX1]: LCM:  [ End    Test     ]  [[File]CreateaFile]  in 0.0320 seconds.
VERBOSE: [BOX1]: LCM:  [ Start  Set      ]  [[File]CreateaFile]
VERBOSE: [BOX1]:                            [[File]CreateaFile] The system cannot find the file specified.
VERBOSE: [BOX1]:                            [[File]CreateaFile] The related file/directory is: c:	est.txt.
VERBOSE: [BOX1]: LCM:  [ End    Set      ]  [[File]CreateaFile]  in 0.0000 seconds.
VERBOSE: [BOX1]: LCM:  [ End    Resource ]  [[File]CreateaFile]
VERBOSE: [BOX1]: LCM:  [ End    Set      ]
VERBOSE: [BOX1]: LCM:  [ End    Set      ]    in  0.0790 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 0.16 seconds
[BOX1 PS] >
[BOX1 PS] > Test-Path C:	est.txt
True  

We get a lot of information back, so let's go over what we see. It initially tells us that it's performing a DSC operation and then tells us about the methods it's using to invoke. This is where we see that the Start-DSCConfiguration cmdlet is just a wrapper over the CIM methods that actually execute the DSC functions. You won't need to know these CIM methods for everyday use, but it's interesting to see the inner workings shown here. The next line tells us that all the subsequent lines come from our target node box1 and were initiated by a user with this SID. It doesn't look too important here as we're running on the same box we've compiled the MOF on, but when we deal with remote pushes, noting which target node had which operations occur on it, it becomes very important. The rest of the lines tell us that the file did not exist and that DSC had to create it. Not so hard, is it?

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

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