为什么我的 powershell DSC 失败并显示消息 "An item with the same key has already been added"

Why is my powershell DSC failing with the message "An item with the same key has already been added"

我们有一个正在执行的 powershell DSC,以使 vmss 达到所需状态。 在我们添加更多参数之前它一直在工作,然后它就坏了。

我从脚本中删除了除参数之外的所有内容,但它仍然不起作用。 完整的错误是

The DSC Extension received an incorrect input: An error occurred while executing script or module 'IISInstall.ps1': An item with the same key has already been added..

Please correct the input and retry executing the extension.

我们甚至在 DSC 中添加了日志记录以尝试进行故障排除。 它甚至似乎没有进入 DSC 的主体。

我做错了什么?

参数名为 $instanceName。我们想用它来向 IIS 添加自定义 header 以跟踪响应来自哪个实例。

事实证明,如果您使用以某种方式进入 DSC 内部的 $instanceName,它永远不会正确部署!

只要从参数列表中删除 $instanceName,它就会起作用。