PowerShell Desired State Configuration (DSC) Journey – Day 16

When I started this original project my intention was to work through all of the individual DSC Resources one at a time, hoping that I could get through them all before they released some more.  Well, that didn’t happen.  On Friday the PowerShell Team released DSC Resource Kit Wave #3, which is freaking awesome.  So, instead of working through the rest on my list, I am just going to start working on a project I probably should have been working on anyways.  I want to build a Configuration to replace using Virtual Machine Manager Templates, with the goal being to be able to deploy multiple, identically configured servers at one time.  I want to do this for a demo I am going to be doing (hopefully before I leave for the PowerShell Summit).

The information on the Hyper-V module can be found here, and I will also be referencing this post on building Composite DSC Resources.  After a lot of time spent looking at the documentation, I am just going to follow along with the example on the TechNet page in creating the various parameters and pieces of the Hyper-V portion of my Configuration.

First, let’s start with the xVMSwitch Resource.

Here is what I started off my Configuration with.

ProTip:  Don’t import the Module before declaring your parameters like I did above.  It will fail miserably.  I should also mention that all of these examples will be done on my PC using Hyper-V Manager because I don’t have access to a functional lab that will allow me to do what I want to do here.  I Invoke the Configuration and get a .MOF file for my PC.

I then push out that Configuration file to my PC using this command.

Here is the Verbose output and a screenshot showing the completed switch.  It amazes me how fast this completed.  If I create a new VMSwitch through the GUI and select the “Use Guest OS” option my computer literally locks up for 5 minutes.


Tomorrow I will work on creating the .VHDX file(s) that are required.