PowerShell DSC Custom Resource Journey – Day 2

Alright, after yesterdays post, I am going to start working on the Configuration needed to build a Hyper-V VM.  First step is to create a switch for my VM to use.  Here we go!

Pretty straightforward right? That was a trick question, I already know the answer to it :). After compiling the Configuration, I attempt to push the Configuration to my computer.

Well what the hell, that’s not very helpful. Access denied to what? There isn’t any information in Windows or the DSC Operational Event Log. Edit:  I realized later that I wasn’t running ISE as Administrator (it was running as my admin account) which is why I got access denied instead of the error message.  I am keeping everything in this post the way I had it, because it might help someone, somewhere, sometime, and it’s a good reminder for me personally. Had I been running ISE as Administrator this is what I would have seen:

So, I had the excellent idea to just try running it from the Console to see if I get a different error. And wouldn’t you know it….

Now that’s an error message I can get on board with! Now after all of this I checked out the TechNet documentation and it doesn’t say anything about not using NetAdapterName when using xVMSwitch. However, on that page when they use Internal as the VMSwitch type, they don’t have a NetAdapterName. So I will give them half credit :). It’s also entirely possible that this is not a surprise to anyone who uses Hyper-V more than I do. Onwards! I remove the offending line from my Configuration and re-compile it. Now when I run it:

dsc53 Excellent! Just for fun, I also deleted this VMSwitch and re-ran the Configuration and re-created it. Because…why not? Next step is going to be “building” a VHD using a previously created .VHDx that has nothing but a fresh install of Server 2012 R2 Standard.