Unexpected Token ‘}’ in Expression or Statement when using $AllNodes in a Desired State Configuration

I was working on testing a custom DSC Resource when I came across a very strange issue. Whenever I tried to build a Configuration like the one below, it failed.

Under the very last curly brace there was a red squiggly line. When I tried to build the Configuration it failed with the error:

It took me nearly an hour and a half to figure out what was causing the issue. Here is the working Configuration. Can you spot the difference?

If you can’t spot the difference, the only difference is that in the second example, there is a space between $AllNodes.NodeName and the curly brace beginning the Node block. As you can imagine I have a serious problem with this, and believe this to be a bug. You will notice that I don’t need a space between the name of the Configuration and the curly brace, so why should I need a space after $AllNodes.NodeName? Also, in the next example, if I change $AllNodes.NodeName to Node MYPC, it doesn’t require a space between the node name and the curly brace either.

All of this testing was done on Windows 10 Enterprise Preview edition with PowerShell Version 5.0.10158.0 . If you also believe this is a bug and should be fixed, vote up the issue on connect here.

Leave a Reply