我的DSC配置如下:
xWebApplication StaffDirectoryApp {
Website = "MySite"
Name = "MyApp"
WebAppPool = "MyPool"
PhysicalPath = $Destination
Ensure = "Present"
PreloadEnabled = $true
}
这似乎工作正常,但我还想使用 AuthenticationInfo 属性(尽管文档似乎说它应该是 AuthenticationInformation,但事实并非如此)。
我能找到的唯一示例是在 GitHub 上的一个单元测试中,它们的用法如下:
AuthenticationInfo = New-CimInstance -ClassName MSFT_xWebApplicationAuthenticationInformation `
-ClientOnly `
-Property @{ Anonymous = $false; Basic = $false; Digest = $false; Windows = $true }
然而,这会产生以下结果:
Convert property 'AuthenticationInfo' value from type 'STRING' to type 'INSTANCE' failed
我应该如何设置这个属性?
答案1
尝试以下语法:
xWebApplication StaffDirectoryApp {
Website = "MySite"
Name = "MyApp"
WebAppPool = "MyPool"
PhysicalPath = $Destination
Ensure = "Present"
PreloadEnabled = $true
AuthenticationInfo = MSFT_xWebApplicationAuthenticationInformation
{
Anonymous = $false
Basic = $false
Digest = $false
Windows = $true
}
}
我不知道为什么代码New-CimInstance
不起作用,但这个应该可以解决问题。