Why Injecting a PowerShell DSC Meta Configuration is not Enough
Published on 15 Dec 2014Tags #Desired State Configuration #DSC #LCM #PowerShell #PSDSC
In a previous post I described how to inject the meta as well as the node configuration. As it is, the Local Configuration Manager (LCM) does not create the scheduled tasks necessary to apply, monitor and correct the configuration. In this post I will explain how to make sure that LCM kicks off.
LCM needs two Scheduled Tasks
The LCM uses up to two scheduled tasks as triggers for its internal operations:
- DSCRestartBootTask is triggered after a reboot.
The following command is executed:
PowerShell.exe -NonInt -Windows Hidden -Comand "Invoke-CimMethod -Namespace root/Microsoft/Windows/DesiredStateConfiguration –ClassName MSFT_DSCLocalConfigurationManager -MethodName PerformRequiredConfigurationChecks -Arg @{Flags = [System.UInt32]2 }"
- Consistency is triggered as configured by the ConfigurationModeFrequencyMins:
The following command is executed:
PowerShell.exe -NonInt -Windows Hidden -Comand "Invoke-CimMethod -Namespace root/Microsoft/Windows/DesiredStateConfiguration –ClassName MSFT_DSCLocalConfigurationManager -MethodName PerformRequiredConfigurationChecks -Arg @{Flags = [System.UInt32]1 }"
These tasks are not present on a newly installed system.
When are the Scheduled Tasks created?
In contrast to what I have implied in my earlier article about injecting a meta and node configuration, it does suffice to drop the metaconfig.mof
into c:\Windows\System32\Configuration
. Although the LCM picks up the configuration, it does not create the scheduled tasks with the effect that no configuration is applied and monitored.
Solution 1: Execute the command recommended by the PowerShell team at Microsoft:
PowerShell.exe -NonInt -Command 'Invoke-CimMethod -Namespace root/Microsoft/Windows/DesiredStateConfiguration –ClassName MSFT_DSCLocalConfigurationManager -MethodName PerformRequiredConfigurationChecks -Arg @{Flags = [System.UInt32]3 }'
Solution 2: Restart the LCM, e.g. by performing a reboot
Solution 3: Apply the meta configuration using Set-DscLocalConfigurationManager
Sidenote on Push Configurations
As soon as a node configuration is pushed to a system using Start-DscConfiguration
, the LCM creates a single scheduled task called Consistency
(see above). Placing the pending.mof
in c:\Windows\System32\Configuration
does not trigger the LCM to apply this configuration.
Update: In contrast to placing a file in the right place, you can also make sure remotely that a configuration is applied. See my post how to remotely prepare a newly created VM.