Desired State Configuration: Cannot bind argument to parameter ‘ResourceKey’ because it is an empty string

Applies To: PowerShell Version: 5.0.10240.16384, xComputerManagement 1.2.2, 1.3.0

I was working on a DSC Configuration to build a Hyper-V host, when I encountered the error shown below.

So, that’s a pretty awesome error, and not one that I can say that I have seen before. I did A LOT of troubleshooting to figure out what was going on (which in the interests of time and space I am going to skip over) and we will get right to the good stuff.

My Configuration had some string parameters that were not assigned any values in the Configuration, or when I was creating the .mof files. Let’s pretend the Configuration looks like the one below. If you just copy and paste and run this, it is going to fail with the error above.

If you remove the section for xComputerManagement, it will work just fine. Also, if you hard code a value into the parameter $ComputerName in the Configuration, or pass it in when you build the Configuration (I have shown both ways below), it will also not error and will work the way you would expect it to.

So, the next question is, why is this? Thankfully, the answer is in the error message once you figure it out. The Name parameter of the DSC resource is the Key value of the resource, and as such it cannot be an empty string (which completely makes sense). It doesn’t throw the error for the File resource, because it’s key value is DestinationPath, which in my example I have coded in as an actual value. How can you tell what the Key property of a DSC Resource is? Look at the example below! Key properties are Mandatory parameters, and as such are shown without being enclosed in square brackets. You can also open up and look at the schema.mof file for the resource which will show you that information as well.

To further illustrate the point, if I run the Configuration below, it is also going to error out.

Leave a Reply