Windows Classroom Series – 28/Oct/2020

Powershell DSC (Desired State Configuration)

  • Powershell DSC helps ensuring resources are correctly configured. Powershell DSC is a declarative way of configuring resources.
  • Powershell DSC is released as a feature of Powershell.
  • Powershell DSC as a set of Powershell Language Extensions
  • A Sample DSC would look like
configuration TemporaryConfiguration 
   File TempFile 
         Ensure = 'Present'
         Type = 'File'
         DestinationPath = 'C:\temp.txt'
         Contents = 'This is sample DSC Configuration'
  • In the above case we are expressing the desired state rather than writing how to create a file.

High level Overview

  • DSC has several steps that can be grouped into three phases
    • Authoring Phase:
      • We begin with writing DSC Configuration script in Powershell.
      • Generate a MOF (Managed Object Format) for the configuration
    • Staging Phase
      • Deploying the MOF into server which can happen in two ways
        • PUSH
        • PULL
    • Execution Phase
      • In this MOF file will be executed by Local Configuration Manager.

Push based Model


Pull Based Model


Hello-World Configuration

  • Create a PS1 file with the Sample DSC Configuration as shown below Preview
  • Now, Generate MOF file by executing the powershell file Preview Preview Preview
  • Lets look into contents of mof
@GenerationDate=10/28/2020 17:55:51

instance of MSFT_LogResource as $MSFT_LogResource1ref
SourceInfo = "D:\\khajaclassroom\\windows\\powershell\\dsc\\hello-dsc\\hellodsc.ps1::8::5::Log";
 ModuleName = "PsDesiredStateConfiguration";
 ResourceID = "[Log]MyMessage";
 Message = "Hello, Welcome to the World of DSC";

ModuleVersion = "1.0";

 ConfigurationName = "HelloDsc";

instance of OMI_ConfigurationDocument


                        MinimumCompatibleVersion = "1.0.0";

                        CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};


                        GenerationDate="10/28/2020 17:55:51";




  • Now lets execute the MOF file by using the cmd-let Start-DSCConfiguration
Start-DscConfiguration -Path .\HelloDSC -Wait -Verbose


  • Powershell works very well in a domain controller. So the lab setup would be as shown below Preview Preview
  • Next Steps:
    • Configuration Data
    • Configuration
    • DSC Resources & Modules
    • Powershell DSC to install web servers

Leave a Reply

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

About learningthoughtsadmin