PowerShell Desired State Configuration (DSC) Journey – Day 20

Yesterday I was driving the struggle bus around because I don’t understand how hash tables work.  Thankfully for me Steven Murawski was kind enough to put an example up of how to use the Configuration Data hash table in a DSC Configuration which you can find here.

Using that example, I modified my Configuration as below and was able to Invoke it with no errors!  I sure just stop here and call it a day, but what fun would that be?

After looking at this I literally spent about an hour thinking about it.  This works, but is it going to do what I want it to do?  No.  I need to be able to specify the ComputerName, and have it renamed to that.  And then a light bulb went off, and this happened.

And I got this awesome error for my trouble.  And yes I know I complicated matters by adding another block of code in there to rename the computer, but that’s the least of my concerns right now.

Alright, well I am pretty sure it doesn’t like the fact that I am renaming my computer in one block, and then using the same name in the other block.  It didn’t occur to me until just now that my code block for DomainJoin is already renaming the computer itself so there is no need to rename it in another code block.  After removing that code block and some more trial and error, this is the Configuration that I got to Inovke and create the .MOF file.  Whether or not this actually ends up working is a whole other matter.  The other issue from looking at the errors I am getting when trying to use [String[]]$ComputerName and the examples on TechNet is that it doesn’t look like using multiple ComputerName is going to work, which throws a wrench into what I am trying to accomplish.  I think I need to sit down and map this out because I have confused even myself at this point.

My brain hurts and I am distracted so I am going to call it quits on this project for today.  More tomorrow.  Probably.  Maybe.