PowerShell v4 Desired State Configuration Deep Dive

During my time at Microsoft TechEd many new things were announced. My all time favorite announcement was PowerShell v4. There are many great things coming out with PowerShell v4, things that I haven’t really gotten a chance to dig into much yet. However the one of the few things I have run through would be the Desired State Configuration which I will refer to as DSC throughout this blog.

DSC is a way to manage the configuration for multiple servers utilizing a single script for the deployment. In the example I will use is managing an IIS Configuration across multiple servers. However as the DSC is developed there will be other usability options for this.

Step Outline:

The DSC requires a couple of steps. It isn’t just a single script you create and execute; but it is very close.

  1. Create a DSC script.
  2. Execute DSC script to create DSC file (MOF File).
  3. Deploy and enact Desired State Configuration file to server(s)

Step 1: Creating a Desired State Configuration File

The first step, in utilizing the DSC is creating the DSC Script. This script is used to generate the DSC file which is a MOF document. To create the DSC Script you can simply open the PowerShell ISE and start writing PowerShell utilizing a couple of new keywords and identifiers.

You will notice in the below example script the keyword configuration, with a nested identifier of Node.

Step 2: Execute DSC script to create DSC (MOF Configuration File)

Once you have finalized, or possibly updated your DSC Script you now have to generate the MOF Configuration File that is actually used to perform the deployment. When you are ready to create this file all you must do is execute the script you created in step one.

Step 3: Deploy and enact Desired State Configuration file to server(s)

Once you have setup your script, and created the MOF Configuration File all you have to do is execute a single cmdlet and it will run and deploy to 1-many servers depending on the script.

Summary:

Overall this is a fantastic new feature and will make a big difference for maintaining a standard configuration across an entire environment. You can combine this with Azure cmdlets and automate the deployment of web servers as your environment starts taking a much higher load.

Note: I used the following TechNet Article and HOL I attended at TechEd to assist in writing this.

Be Sociable, Share!
  1. PowerShell Day 2014 @MVPSKILL.COM Part 2 | Buffbear - pingback on March 2, 2014 at 3:19 am
  2. Is there any blog post which says how to connect the agent (target node) and the pull server ?

    • I do not have one, however there are some blog posts on PowerShell.org about DSC that have been on my Need to Read list, I’d suggest looking through those first.

  3. Thanks for sharing. The new features in PowerShell v4 are amazing, most of all DSC

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

 

Trackbacks and Pingbacks: