This is eight part of 10 series blog on LCM APIs and Internals. In last part, we saw “How to Test Configuration drifts at target Nodes” using three different methods, namely WMI, CIM and DSC Cmdlet.
In this post, we will continue our journey and would see “How to Test Configuration drifts at target Nodes” using the same three methods.
Till now, we saw sending, applying and testing of configurations on target nodes, however now its time to look at other directions. Once the configuration is send and applied, at time there could be requirement to rollback the configuration. It could be due to various reasons. DSC provides us with the necessary infrastructure to roll back an applied configuration. Rollback of configuration means re-applying the old configuration by replacing the current configuration. In this case, content of Current.mof file and previous.mof files are swapped. After swapping, the configuration in current.mof file is applied on to the target node. There is a DSC cmdlet names Restore-dscconfiguration that rollbacks and apply the old configuration.
Using DSC Cmdlet
Restore-DSCConfiguration cmdlet is used to restore previous configuration as current configuration on a target node. After restoration, the new configuration is also applied on the target node. The execution and syntax is shown here.
Windows Management Instrumentation (WMI)
We can use WMI Cmdlet to test the Configuration. We can see in Image 5 that we are invoking a WMI method named “Rollback” on class “MSFT_DSCLocalConfigurationManager” available in WMI namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”.
Common Information Model (CIM)
All the steps remain same with that of WMI however the only difference is using a CIM cmdlet instead of WMI cmdlet and parameters are sent as hashtable.
Hope this Post helps!