Deploying a Desired State Configuration Web Host Using PowerShell

Posted on January 15, 2014 by Damian Flynn in PowerShell with 0 Comments

One of the coolest features introduced in Windows Server 2012 R2 is packaged as part of the Windows Management Framework and PowerShell 4.0, a feature which is commonly referred to as Desired State Configuration (DSC).

This feature takes all the benefits of using PowerShell to the next level, and finally enables us to manage our Windows hosts just like their Linux counterparts with configuration-based management. The approach is extremely flexible and unleashes an awesome amount of power to keep our servers standardized. Best of all, the feature has been backported to earlier versions of Windows, which implies that we can influence the old and the new!

In this post, I am going to share a script which permits us to take a Windows 2012 R2 server and configure it so that it is ready to deliver our configurations to our clients through HTTP. This configuration is better know as a DSC web-based pull server.

Sponsored

Web-Based Configuration Server

To successfully complete the configuration you will need to use an Administrative PowerShell session, and also modify the host header (Section 3), to match the name of the website from which you wish to publish the service (in my example this is PSDSCPullServer.diginerve.net). Additionally, for the host header to function, we need to add this name to our DNS service as a A record or CNAME, resolving to the IP of the chosen server.

Sponsored

Let’s take a closer look at how this script is structured and what it is doing.

  • Section 1: This starts off the process by adding the Windows Feature for DSC, along with all its dependencies, which will include adding IIS and Management ODATA to the server.
  • Section 2: We create a new folder in c:\inetpub\wwwroot, which will be used to host the content for the pull server website. We then copy over the supporting files necessary to create the web service from the default PowerShell folder on the server to this folder.
  • Section 3: We load up the IIS modules and create a new application pool with local system authentication for the website.
  • Section 4: We then define our new website, including the host header, the path to the folder we created and populated in Section 2, and reference the name of the application pool we created in Section 3.
  • Section 5: We update the IIS configuration to allow the security settings in our Web.Config file take effect.
  • Section 6: We finally update the application settings in our Web.Config, adding four new parameters that configure the web service we just created.

After a successful execution of the script, your new web-based DSC pull server should be online and ready for service.

You can validate your work by pointing your web browser to the new web service. Assuming the procedure has worked, you should be presented with some XML similar to the screen shot.

Deploy a Desired State Configuration Web Host using PowerShell

Congratulations! You are now ready to begin the real fun part, configuring the Desired State Configurations. We’ll cover that in the next post.

Sponsored

Tagged with , , , , , ,