PowerShell DSC Custom Resource Journey – Day 4

Alright, today I am going to build a Hyper-V VM on my local workstation using the xVMHyperV Resource.  Here is what my current Configuration script looks like.

If you remember from my last post, the xVHD Resource only creates VMs with Dynamic Memory and Dynamic disks. The disk I am attempting to use is a Fixed disk, so I am interested to see if this actually works or not.

I run the Configuration and RED TEXT EVERYWHERE!

All that red text needs to say is “hey dummy, when you use Name = $VMName, it needs to be Name = “$VMName” or I have no idea what to do with it”.
So, I fixed that issue and everything works fantastic. Now, let’s run the Configuration and see what happens. I should also mention here that I intentionally set MaximumMemory and left out MinimumMemory because I wanted to see how it handled the dynamic memory settings when it creates the VM.

And true to form (for me anyways) something completely head scratching happens.

What. The. Hell. For starters I have already executed the xVMSwitch portion of this Configuration probably 10 times with no errors. Looking over my Configuration it occurs to me that I have no DependsOn parameters, and that DSC was looking at the entire Configuration, got to the xVMHyperV part, and was like “There is no switch with that name. FAIL”.

So, I add this to my xVMHyperV portion of the Configuration and try again!

Nope, same exact thing. This time I comment out the entire xVMHyper section and run it. Same thing. Now I am REALLY confused. You are full of crap DSC!

I have run this successfully probably 10 times with no problems before today. I really have no idea what’s going on.

Because I have no idea what else to do, lets take this time to use PowerShell Get!

All for naught, the same thing happens. I am absolutely, completely stumped. I guess I will come back to this later. Later means I reboot my computer in search of a magical solution.

Well. Whatever. I am stubborn so I wait a minute and run it again.

OMG THE MAGICAL COMPUTER REBOOT STRIKES AGAIN!

Of course. So let’s return to our previously scheduled programming. Finally a useful error message.

Duh Jacob. I change the value to 4GB and try again. Important to note that the 4GB does not belong in double quotes :). Not that I did that or anything.
Yahtzee!

Since I didn’t set the MinimumMemory it defaulted to 512MB, which is handy to know I suppose. And it also attached the .VHDX, so that’s nice to know that it can attach a fixed disk .vhdx if you need to.