How to Stop Configuration at target Nodes – part 10

This is tenth and last part of 10 series blog on LCM APIs and Internals. In last part, we saw “How to Test and re-apply Configuration 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 Stop Configuration at target Nodes” using the same three methods.

DSC LCM also provides with a method named “StopConfiguration” whose purpose is to stop any configuration that is in process of applying the configuration. There is no equivalent DSC Cmdlet for this method. Also, I have not seen any practical usage of this method since configurations are normally applied within seconds and we can roll back the configuration if the configuration is not acting as intended. It returns a ReturnValue parameter. A value of Zero signifies that either no configuration was in progress or it was able to stop the configuration. Any non zero value signifies an error and the configuration application could not be stopped.

Windows Management Instrumentation (WMI)

We can use WMI Cmdlet to test and apply the Configuration. We can see in Image below that we are invoking a WMI method named “StopConfiguration” on class “MSFT_DSCLocalConfigurationManager” available in WMI namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”.

LCM-10-01

The result of executing the above command results the below. The important thing to note that the ReturnValue is Zero meaning success.

LCM-10-02

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.

LCM-10-03

The result of executing the above command results the below. The important thing to note that the ReturnValue is Zero meaning success

LCM-10-04

Hope this Post helps!

Cheers!

How to Test and re-apply Configuration at target Nodes – part 9

This is ninth part of 10 series blog on LCM APIs and Internals. In last part, we saw “How to Rollback Configuration 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 and re-apply Configuration at target Nodes” using the same three methods.

There are occasions when you would want to check the configuration drift and having found one would like to reapply the configuration to bring back the target node to its desired configuration state. This can be achieved by combining two of the previous two methods. Testing of Configuration and applying configuration. If we want to achieve the same objective using a single method, DSC provides us with the PerformRequiredConfigurationChecks method. Using this method, you can not only test but also re-apply configuration if there is a drift.

There is no equivalent DSC cmdlet for this function.

Windows Management Instrumentation (WMI)

We can use WMI Cmdlet to test and apply the Configuration. We can see in Image below that we are invoking a WMI method named “PerformRequiredConfigurationChecks” on class “MSFT_DSCLocalConfigurationManager” available in WMI namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”.

LCM-09-01

The result of executing the above command results the below. The important thing to note that the ReturnValue is Zero meaning success.

LCM-09-02

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.

LCM-09-03

The result of executing the above command results the below. The important thing to note that the ReturnValue is Zero meaning success.

LCM-09-04

Hope this Post helps!

Cheers!

How to Rollback Configuration at target Nodes – part 8

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.

LCM-08-01

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”.

LCM-08-02

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.

LCM-08-03

Hope this Post helps!

Cheers!

How to Test Configuration drifts at target Nodes – part 7

This is seventh part of 10 series blog on LCM APIs and Internals. In last part, we saw “How to Send and Apply Configuration to 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.

Last few posts discussed and described the process of sending and applying configurations to the target nodes. In this post, we will look at testing the configuration for their validity and check their drifts from their expected configuration. If there is a configuration drift then either we can re-apply the configuration using ApplyConfiguration method shown before or leave it as is.

Testing the validity of existing configuration on target nodes is responsibility of LCM. This method return true or false as “InDesiredState” depending on whether the target node is matching the expected configuration or not. It is to be noted that testing of configuration only checks the current configuration with expected configuration. It does not apply the configuration to remove the gap or drift in configuration. There is a DSC cmdlet names Test-dscconfiguration that tests the configuration together.

Using DSC Cmdlet

Test-DSCConfiguration cmdlet is used to test a target node for its validity against expected configuration. It need not be send any parameters and it would check the validity of the node on which it runs. To check the validity of a remote server on network, it accepts a CIMSession which can be configured for a remote server. The execution and syntax is shown here.

LCM-07-01

Windows Management Instrumentation (WMI)

We can use WMI Cmdlet to test the Configuration. We can see in Image below that we are invoking a WMI method named “TestConfiguration” on class “MSFT_DSCLocalConfigurationManager” available in WMI namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”. This method has two output parameters. “InDesiredState” results into true or false depending whether there is a configuration drift. “ResourceID” does not return any value and is empty.

LCM-07-02

The result is shown here.

LCM-07-03

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.

LCM-07-04

The result is shown here.

LCM-07-05

Hope this Post helps!

Cheers!

How to Send and Apply Configuration to target Nodes – part 6

This is sixth part of 10 series blog on LCM APIs and Internals. In last part, we saw “How to Apply Configuration to target Nodes” using three different methods, namely WMI, CIM and DSC Cmdlet.

In this post, we will continue our journey and would see “Sending and Applying Configuration to target Nodes” using the same three methods.

Last couple of psts discussed and described the process of sending configurations to the target nodes. In this post, we will look into sending and applying configurations to target nodes as a single step. We have seen that sending and applying configuration to target nodes is responsibility of LCM. There is a DSC cmdlet names start-dscconfiguration that sends and applies the configuration together.

Using DSC Cmdlet

We know the usage of Start-dscConfiguration from previous blog posts. It takes path of the mof file to be send to the target node and also apply the same.

LCM-06-01

Windows Management Instrumentation (WMI)

We can use WMI Cmdlets to send and Apply Configurations stored with DSC LCM. We can see in Image below that we are invoking a WMI method named “SendConfigurationApply” on class “MSFT_DSCLocalConfigurationManager” available in WMI namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”. The method take UInt8Array type configurationData parameter and Boolean Force parameter. It sends the configuration as Configurationdata to the target node and applies the same immediately on the target node. There is no generation of Pending.Mof file in this case. The content of Configurationdata finds its place within Current.mof file. The content of Current.mof file is placed within Previous.mof file.

LCM-06-02

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.

LCM-06-03

Hope this Post helps!

Cheers!