PowerShell Desired State Configuration (DSC) Journey – Day 6

At the end of yesterday’s article I talked about how I was going to build a new DSC Test server so I could test my pull configurations.  Well not only did I do that, but I decided to make it server core, with the intention of seeing just how much of it I can configure using Configurations created by DSC Resources.

Here we go!

My new server name is just DSCTEST-01.  It is running Server 2012R2 Server Core.  I have done nothing to configure it so far.  First step is going to be to set the IP Address and get this thing on the network.

Let’s take a look at the DSC Resources that are available to me (keep in mind I have imported all the modules released in DSC Waves 1 and 2) using the Get-DSCResource command.  One immediately jumps out at me, xIPAddress.  Let’s investigate further.

The xIPAddress Resource has the following properties:

  • InterfaceAlias (Mandatory)
  • IPAddress (Mandatory)
  • AddressFamily
  • DefaultGateway
  • DependsOn
  • SubnetMask

That’s all wonderful, but where is the DNS Server information?  Looking through my list of available resources I see one for xDNSServerAddress.  Perfect.  We will come back to that later.

Here is what I have for Configuration script, with some things added (like extra parameters) with an eye on reusing this in the future.  One thing I am not sure about is the InterfaceAlias.  I have no idea what InterfaceAlias is currently (and I intentionally didn’t check so we can see what happens).

After yesterday I now have a DSC Pull Server, so let’s go back to the Don Jones DSC E-Book and go through configuring a server to pull a configuration.  First we need to generate the MOF (Managed Object Format) file.  We already know how to do that, so I Invoke the Configuration and….get this.

Well.  Alright.  I run Get-DSCResource and verify that xIPAddress is the actual name.  Running Get-DSCResource -Name xIPAddress also shows all the correct information.  My only thought is that I need to import the module it belongs to, in this case xNetworking in the Configuration.  So let’s try that.  So here is a code snippet showing where I added the Import-Module command in my Configuration.

No luck.  Same error.  I vaguely remember a DSC article where the author imported DSC resources and I look that up.  It can be found here.  The command I actually need to use is:

Invoke the Configuration, and it works.  I do get this error:

Looking back at the xIPAddress properties, this makes sense.  It specifically says that DefaultGateway is [string] and not [string[]] like DependsOn is.  I make those changes to my Configuration script (for IPAddress as well) and Invoke it again.  Ok this time it doesn’t like my “IPv4” property apparently.

I try a couple of things and it doesn’t like any of them.  Doesn’t work without quotes.  Doesn’t work with single quotes.  What the hell…..I look up the xNetworking Module documentation and find something interesting.  The SubnetMask isn’t something like, it’s the local subnet size, such as 24.   Maybe that is the entire problem.  I Invoke the Configuration again, using 24 as the SubnetMask, and GREAT SUCCESS!


I would have never guessed in a million years that SubnetMask was going to take a size, instead of the actual mask.  Raise your hand if you thought the phrase “Microsoft documentation saves the day” would be in this article.

Now, back to your regularly scheduled programming of pulling this Configuration from the PullServer.  First step, create the GUID.

Now I will copy the .MOF file generated above to my DSC PullServer.

Everything looks to complete fine, but just to be sure I verify and everything looks great so far.


Next we run the command New-DSCCheckSum $dest and verify it is present on the PullServer.


So far so good!  Next step, still following the DSC E-Book instructions is to create a Configuration to make a server pull its Configuration.  I am using the same one in the book, modified slightly.

I run into a couple of issues here.  First is that I can’t find the computer, for obvious reasons, because I configured it that way.  I quickly use PowerShell to rename the computer, join it to the domain, and disable the Windows Firewall.  I do all that and verify I can ping by just ComputerName and by FQDN.  I Invoke the Configuration and, same error.  I quickly run through my mental checklist.  What is the execution policy on DSCTEST-01?  It’s remote signed.  Is PSRemoting enabled (I think it should be since it’s 2012 R2) but I run Enable-PSRemoting anyways.  Once I do that, the Configuration runs successfully.


Here is what the output of the Configuration looks like:


This may take a while to actually pull (up to 30 minutes according to the E-Book) so we are going to stop here for today.  Tomorrow we will see if it worked or not!

Things I Learned:

  • How to properly import a DSC Module
  • How to configure a server to Pull its DSC Configuration
  • How to rename a computer, join it to a domain, and disable all firewalls using PowerShell
  • SubnetMask Property of xIPAddress Resource uses a size, not the actual mask

Questions I Have:

  • Why did I have to run Enable-PSRemoting to get that to work?
  • How do I troubleshoot a server Pulling its DSC Configuration?
  • How can I see the status of a DSC Configuration?
  • How can I pull the GUID out for a specific server for future Configurations? (Is this even necessary?)