Powershell DSC使用不正确的证书文件进行encryption,其中节点名称部分匹配?

我认为DSCselect用于凭证encryption的证书文件(例如服务资源和PSCredential)的方式存在一个错误。

如果节点名称包含在后续节点名称中(节点顺序重要),则DSCconfiguration使用AllNodes集合中错误的CertificateFile。 这意味着发送给节点的encryption值可能是错误的。

这里有一个repro包括两个testing。 两个testing都会失败,但是第一个testing成功(带有错误的证书):

$password = ConvertTo-SecureString "password" -AsPlainText -Force $serviceCredential = New-Object System.Management.Automation.PSCredential ("username", $password) $currentPath = Split-Path -Parent $MyInvocation.MyCommand.Definition $thisShouldNotWork = @{ AllNodes = @( @{ NodeName = "web1" CertificateFile = "nonexistentfile" }, @{ NodeName = "customerweb1" CertificateFile = "$currentPath\mycert.cer" } ); } $thisDoesNotWork = @{ AllNodes = @( @{ NodeName = "web1" CertificateFile = "nonexistentfile" }, @{ NodeName = "customerweXb1" CertificateFile = "$currentPath\mycert.cer" } ); } Configuration DscWebServer { Node $AllNodes.NodeName { Service "Service Started" { Name = "MyService" State = "Running" Credential = $serviceCredential } } } Write-Host "Test 1" -ForegroundColor Blue -BackgroundColor White DscWebServer -OutputPath .\DSC -ConfigurationData $thisShouldNotWork Write-Host "Test 2" -ForegroundColor Blue -BackgroundColor White DscWebServer -OutputPath .\DSC -ConfigurationData $thisDoesNotWork 

我已经在Connect上报道了这个,但是想在这里提出来,以防万一有帮助,或者我所做的事情有些不寻常。 任何人都可以解释此行为?

更新:微软确认这是一个错误,并在2015年5月修复它。我得到了这样的反馈:“这个问题已经修复WMF5四月预览,请让我们知道,如果你不同意:)”

这很有趣。 你能确认每个testing的输出是什么吗? testing2实际上是否会抛出exception?

我不会说你做了什么不寻常的事情,因为DSC是为了处理多个节点而devise的,但是仍然只有less数人使用DSC,使用安全凭证的人数更less。

另外,我想我们中的很多人一直在为每个节点使用一个configuration,这将会阻止这种行为。

这对你来说当然也是一个可行的解决方法,但是需要改变你的工作stream程。

要使用您现有的configuration数据,您可以解决这个问题:

 foreach($node in $thisShouldNotWork.AllNodes) { DscWebServer -OutputPath .\DSC -ConfigurationData @{AllNodes = @($node)} } 

如果可能的话,我将尽可能地重现这一点,以便我可以将我的投票和repro描述添加到连接报告中。