PowerShell Desired State Configuration (DSC) Journey – Day 19

While I have been exploring using DSC I have always been thinking about how I can best utilize it in my environment.  We are a predominantly Hyper-V environment, and currently use Virtual Machine Manager(VMM) to handle building all of our VMs.  In my last post I explored creating a VM, but quickly ran into a couple of issues.  The memory and disk settings default to dynamic, which isn’t what we use except in a couple of specific situations.  You also have to specify an install directory to store the hard disks and specify a specific host.  In VMM it will “suggest” a host on the cluster as well as a default location which almost never ends up being used.  I came across this article  a while back and decided to give this a whirl to see if it would work better for what I wanted.  Another option of course is just to build all the servers you want and then push out a Configuration to them to do what needs to be done or to download one from a Pull server.  I don’t have strong feelings right now about doing it either way, so I am just going to try this and see how it goes.

First, I have built a new Server 2012R2 VM in VMM.  I am going to turn this into a template after injecting the DSC Configuration files and then deploy a VM using the specified Configuration to see what happens.  The template will just be called Server2012R2_DSC_Template.  I’ve installed all the latest updates, including KB 2883200 as specified in the article.

I have previously created the Configuration below.  I can tell you right now it won’t work the way that I intended before I looked at this more closely.  For one thing, if I want this thing to join to the domain, I am going to need to store the password in plain text as it talks about in the xComputer Management Module Resource TechNet article.

If I try to Invoke that Configuration I get the error below.  This doesn’t really make sense because even I use localhost for instance I get the same error.  This probably is going to require a blog article on its own to explore it further but for now I am just going to deal with it because the TechNet article also provides a work around.

Using the information in the article I add this to the bottom of my Configuration file:

And I get this tremendous error message.

Well, that doesn’t make any sense.  I copied and pasted directly from the article, and just changed localhost to $ComputerName.  I put $ComputerName inside of double quotes, and still the same error.  I am extremely puzzled.  Google isn’t of any help with this error message either.  I then try replacing NodeName in the AllNodes hashtable with ComputerName because that is what I am using and in the example it’s called NodeName.  And I still get the same error.  Even crazier is that if I comment out that entire NodeName line I still get the same error message.  Then I thought I was onto something because I realized I had forgotten the semi-colon after NodeName = $ComputerName, but that didn’t make any difference either.

I try about a 40 different things, none of which work.  I think this is as good a place as any to leave off today.  Hopefully my subconscious will figure out what stupid thing I am doing wrong and I will pick this up again tomorrow.