Latest Posts

Basics Concepts of Powershell Desired State Configuration(DSC)

In this post, i explained some basic concepts of DSC.  Before getting into DSC, you need to know what is WMI, CIM & LCM

WMI ->

  • WMI is short for Windows Management Instrumentation and it is available in all Windows Operating system.
  • It provides the information about local and remote system. The information gathered by WMI stored under  %SystemRoot%\System32\Wbem\Repository on local system. The repository is the heart of WMI.
  • We can use VBScript or Powershell script to get the system information from WMI.


What is CIM & Different between CIM and WMI ->

  • CIM is the common information model.

“CIM provides a common definition of management information for systems, networks, applications and services, and allows for vendor extensions. CIM’s common definitions enable vendors to exchange semantically rich management information between systems throughout the network.”

  • In Powershell v3, Microsoft introduced a new set of cmdlets to manage any system that complies with CIM.
  • The CIM Cmdlets are very similar to WMI Cmdlets that have been in Powershell. The Difference between the two sets of cmdlets is that there are many more CIM cmdlets than WMI cmdlets.

For Example, the below two cmdlets returns the same information.

Get-WmiObject CIM_DiskDrive
Get-WmiObject Win32_DiskDrive


LCM ->

  • LCM is short for Local Configuration Manager and. Local Configuration Manager(LCM) is heart and mind of DSC. It runs on every system.
  • Once a PowerShell DSC has been applied to a system, Local Configuration Manager periodically checks whether the applied configuration is still valid or if drift has occurred.
  • If the ConfigurationMode property is set to ApplyAndAutoCorrect, then at the configured interval, if drift has occurred, it will reapply the required configuration automatically

You can check applied LCM Configuration Property by running below command on the local system. we can change this settings also.



Powershell DSC ->

  • Desired State Configuration (DSC) is new features in PowerShell 4.0, Windows PowerShell 5.0.
  • PowerShell version 4.0 automatically with Windows 8.1 and Server 2012 R2 and no installation is required.

” DSC is a new management platform in Windows PowerShell that enables deploying and managing configuration data for software services and managing the environment in which these services run.

    DSC provides a set of Windows PowerShell language extensions, new Windows PowerShell cmdlets, and resources that you can use to declaratively specify how you want your software environment to be configured. It also provides a means to maintain and manage existing configurations m ”

You can use DSC for below scenarios.

  • Enabling or disabling server roles and features
  • Managing registry settings
  • Managing files and directories
  • Starting, stopping, and managing processes and services
  • Managing groups and user accounts
  • Deploying new software
  • Managing environment variables
  • Running Windows PowerShell scripts
  • Fixing a configuration that has drifted away from the desired state
  • Discovering the actual configuration state on a given node

Deployment mode: There are two deployment modes in DSC

1. Push mode – This method is to apply configuration to target systems.

2. Pull mode – The target systems request the configuration from Pull Server and apply it locally. We can use this method when we go for large scale deployments.

Pls refer below link to know more about Push & Pull mode 


Example :

The below configuration script is named as “firstconfiguration” and targeted to Local PC. it uses the Push deployment mode.

configuration firstconfiguration
node AD       # Local PC name, we can use multiple PC names
WindowsFeature xps       # resource and it can be any name
Name = “xps-viewer”       # Windows Feature in Server Manager
Ensure = “Present”          # Make sure that xps-viewer windows feature is present on the server
firstconfiguration -outputpath “c:\temp”    # MOF file Location
Start-DscConfiguration -path “C:\temp” -wait -verbose -force   # Apply configuration to target nodes (or server)


Remender that , PowerShell script doesn’t get sent to target nodes. The script produces a MOF, which is sent to target nodes. The idea behind MOFs is to apply configuration on non-Windows computers)

Once we execute this script,

1. MOF file(AD.mof) will be generated on locally under “C:\temp” .

2. Target node (or Server) accept the MOF file and accomplish the configuration process.

MOF File content:

@GenerationDate=07/17/2015 22:30:15
instance of MSFT_RoleResource as $MSFT_RoleResource1ref
ResourceID = "[WindowsFeature]xps";
 Ensure = "Present";
 SourceInfo = "C:\\Users\\Administrator\\Documents\\Powershell Training\\1.ps1::5::5::WindowsFeature";
 Name = "xps-viewer";
 ModuleName = "MSFT_RoleResource";
 ModuleVersion = "1.0";
instance of OMI_ConfigurationDocument
 GenerationDate="07/17/2015 22:30:15";

Hope this post helps!

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: