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
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.
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.
Hope this post helps!