How to Retrieve DSC Configurations – part 3

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

In this post, we will continue our journey and would see “How to Retrieve DCS Configurations” using the same three methods.

In addition to the Meta configuration properties, LCM also stores the configuration information itself.

Using DSC Cmdlet

DSC module provides cmdlet named Get-DSCConfiguration. Running this command without any parameter will run the command on local computer and return its properties of LCM Meta Configuration.

PS C:\WINDOWS\system32> Get-DscConfiguration

We can also run this command with CIMSession as argument to return the properties of a remote target mode. In this case, we are returning the LCM properties of SQL01 computer.

PS C:\WINDOWS\system32> $Session = New-CimSession -ComputerName “SQL01”
PS C:\WINDOWS\system32> Get-DscConfiguration -CimSession $Session

The output would look like below. The result could be different in your’s machine

LCM-03-01

Windows Management Instrumentation (WMI)

We can also use WMI Cmdlets to read the Configurations stored with DSC LCM. We can see in Image below that we are invoking a WMI method named “GetConfiguration” on class “MSFT_DSCLocalConfigurationManager” available in WMI namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”. The method returns an object having “Configurations” as property containing all the configuration stored with LCM.

LCM-03-02
LCM-03-03

Common Information Model (CIM)

This method is very similar to the WMI method but it uses the CIM cmdlets for reading the Configuration stored by DSC LCM. We can see in Image 6 that we are invoking a WMI method named “GetConfiguration” on class “MSFT_DSCLocalConfigurationManager” available in CIM namespace “ROOT\Microsoft\Windows\DesiredConfigurationManager”. The method returns an array having “ItemValue” as property containing all the Configuration stored with LCM.

lCM-03-04

Hope this post helps!

Cheers!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s