Building a Desired State Configuration Pull Server
Quick recap, I’m working through a series of posts about the Desired State Configuration infrastructure that I’m building at Stack Exchange, including some how-to’s.
The High Points
- Overview
- Configuring the Pull Server (REST version) (this post)
- Creating Configurations (one of two, two of two)
- Configuring Clients
- Building Custom Resources
- Packaging Custom Resources
- Advanced Client Targeting
I started with an overview of what and why. Â Today, I’m going to start the how.
Building a Pull Server
I’m going to describe how to do this with Server 2012 R2 RTM (NOTE: this is not the General Availability  release, so there may be changes at GA), since that’s the environment I’m working most in.  If there is enough demand, I may follow up with how to do this using the Windows Management Framework on downlevel operating systems after the GA version of WMF 4 is released.
The first step is adding the required roles and features, including the DSC Service.
Add-WindowsFeature Dsc-Service Fortunately, the Dsc-Service feature has the right dependencies configured so IIS, the correct modules, and the Management OData Extension are all enabled.
Next we need to set up the IIS web site:
- Create an directory to serve the web application from (I’ll use c:\inetpub\wwwroot\PSDSCPullServer)
- Copy several files from $pshome/modules/psdesiredstateconfiguration/pullserver (Global.asax, PSDSCPullServer.mof, PSDSCPullServer.svc, PSDSCPullServer.xml) to this directory.
- Copy PSDSCPullServer.config and rename it to web.config
- Create a subdirectory named “bin”.
- Copy one file from $pshome/modules/psdesiredstateconfiguration/pullserver (Microsoft.Powershell.DesiredStateConfiguration.Service.dll) to the “bin” directory.
- In IIS, create an application pool that runs under the “Local System” account.
- In, IIS, create a new site (or application in an existing site or just use the existing default site)
- Point the site or application root to the directory you designated as the root of the site.
- Unlock the sections of the web config as below
$appcmd = "$env:windir\system32\inetsrv\appcmd.exe" & $appCmd unlock config -section:access & $appCmd unlock config -section:anonymousAuthentication & $appCmd unlock config -section:basicAuthentication & $appCmd unlock config -section:windowsAuthentication Now we need to set up the location where the pull server content will be served from. Â Installing the DSC Service feature creates a default location ( $env:programfiles\WindowsPowerShell\DscService ). Â There’ll you find sub-directories for configuration and modules. Â We can use these folders or we can create another location. Â I’m going to stick with the defaults for now. Â We’ve got a few steps left.
First, we need to copy the Devices.mdb from $pshome/modules/psdesiredstateconfiguration/pullserver to the root of our pull server data location (in this case, $env:programfiles\WindowsPowerShell\DscService )
Update the web.config app settings with the following settings:`After that your pull server should be up and running. Â You should see something like this if you navigate to http://yourpullserver/psdscpullserver.svc
Related Articles
Media Sync: Organize Your Photos and Videos with PowerShell
Do you have photos and videos that you have taken over the years that are scattered all over the place? Do you want to have all your photos and videos organized? Do you want all your photos and videos to have a standardized naming scheme? If you answered YES to these questions, then this is the post for you. In this post, I will provide you with the PowerShell code and examples for how to use the Media Sync script.
NetNeighbor Watch: The PowerShell Alternative To Arpwatch
In this post, we are going to setup NetNeighbor Watch on a Raspberry Pi. NetNeighbor Watch can keep an eye on your network and send you an email when a new host is discovered. NetNeighbor Watch is done completely in PowerShell. The results are very similar to those of arpwatch. NetNeighbor Watch is for anyone that wants more visibility into the wireless or wired devices on their network. We will also setup a weekly email report with all of the known hosts on your network.
Creating a PowerShell Module to Improve Your Code
Do you have PowerShell code that you reuse in your scripts over and over? Do you have server names hard coded in variables? Are you using a text file or CSV file to import server names? Do you find yourself only utilizing one server out of a cluster of servers to make your PowerShell commands? These are the questions I asked myself and the answer used to be YES. In this post, I will go over how you can store your infrastructure server information in a SQL database and call that data from a custom PowerShell module.