This is fifth part of 10 series blog on LCM APIs and Internals. In last part, we saw “How to Retrieve DCS Configurations” using three different methods, namely WMI, CIM and DSC Cmdlet.
In this post, we will continue our journey and would see “How to Send Configuration to Nodes” using the same three methods.
Last post discussed and described the process of sending configurations to the target nodes. In this post, we will look into applying configurations to target nodes. Applying configuration to target nodes is responsibility of LCM. There is no equivalent DSC cmdlet for applying the configuration. Applying configuration means using previously sent configuration and applying the same to the target node. The configuration is applied to the target node by reading the pending.mof file available at “C:\Windows\System32\Configuration\”.
Windows Management Instrumentation (WMI)
We can use WMI Cmdlets to Apply Configurations stored with DSC LCM. We can see in Image below that we are invoking a WMI method named “ApplyConfiguration” on class “MSFT_DSCLocalConfigurationManager” available in WMI namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”. The method does not take any parameters and hence applies the configuration on the node where it is invoked.
The result of applying the configuration through WMI is shown here.
Common Information Model (CIM)
This method is very similar to the WMI method but it uses the CIM cmdlets for applying the Configuration stored by DSC LCM as a result of sending the configuration. We can see in Image below that we are invoking a WMI method named “ApplyConfiguration” on class “MSFT_DSCLocalConfigurationManager” available in CIM namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”. All the steps remain same with the only different of using a CIM cmdlet instead of WMI cmdlet and also there are no parameters send using this method.
The result of invoking ApplyConfiguration method of LCM is that it deletes any file named pending.mof at “C:\Windows\System32\Configuration” and apply the configuration from it. The content of pending.mof file becomes the content of current.mof file at the same location. Also, whatever was the content of current.mof file becomes the content of previous.mof file. We will see that the content of previous.mof file becomes the content of current.mof file when we use the rollback function of LCM.
Hope this Post helps!