PowerShell Desired State Configuration (DSC) Journey – Day 18

Yesterday I created a VHD to use for building a VM.  Today I am going to take that VHD (and the previously created VMSwitch) and create a Virtual Machine using the xVMHyperV Resource.

Here are all the Properties for this Resource

Based on all of that information and what I have done so far, here is what I have added to my Configuration:

I am pretty sure I have everything covered there, but I am sure I am overlooking something, so let’s Invoke this Configuration and see what breaks :).  Yay Errors!

So the Name Property of the VMHyperV Resource can’t take an array of names, it has to be one.  So let’s try an idea from this article on reusing existing Configuration scripts in PowerShell.

The .MOF file is created with no errors.  Now let’s try to build this thing and see what happens.  As I expected, it hated my MaximumMemory number.

4GB is equal to 4294967296 Bytes so let’s try that and see what happens.  I also really hope it doesn’t set the memory for this VM as Dynamic.  New errors!

Umm.  It does…..what the crap!  Screenshot for proof!

dsc28

I am guessing it is a syntax issue because I didn’t include the .vhdx in my path because I was hoping it would just find it and recognize it, but that clearly didn’t happen.  After much trial and error that I spared you from, I came up with this as my VHDPath.

And then I got this slightly different error.

Sidenote:  I clearly need to go back and re-read my PowerShell in a Lunches book to figure out why things with parameter names in them don’t work the way I expect them to.  Here is the next VHDPath I will attempt:

GREAT SUCCESS!

That was pretty impressive how quickly that took.  And of course it created it with Dynamic Memory.  Blah.  Not what I wanted to see.

I am not sure what I will cover tomorrow but I think I have a pretty good idea!  It will more than likely have something to do with this article.