Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PowerShell DSC:xWebSite错误:所需的网站绑定对网站无效_Powershell_Azure_Dsc_Azure Automation - Fatal编程技术网

PowerShell DSC:xWebSite错误:所需的网站绑定对网站无效

PowerShell DSC:xWebSite错误:所需的网站绑定对网站无效,powershell,azure,dsc,azure-automation,Powershell,Azure,Dsc,Azure Automation,场景:尝试使用Azure Automation帐户使用DSC创建https网站。我得到下面的错误。你也面临同样的情况吗?任何帮助都会很好。 HTTP绑定工作正常 Windows 2012 R2 XWebAdministration模块版本:1.17.0.0 错误:PowerShell DSC资源MSFTxu网站无法执行测试目标资源功能,错误消息:所需的网站绑定对网站无效 DSC节点配置: foreach ($Site in $Node.Sites) { x

场景:尝试使用Azure Automation帐户使用DSC创建https网站。我得到下面的错误。你也面临同样的情况吗?任何帮助都会很好。 HTTP绑定工作正常

Windows 2012 R2

XWebAdministration模块版本:1.17.0.0

错误:PowerShell DSC资源MSFTxu网站无法执行测试目标资源功能,错误消息:所需的网站绑定对网站无效

DSC节点配置:

foreach ($Site in $Node.Sites)
        {
            xWebSite "$($Site.Name)WebSite"
            {
                Ensure = "Present"
                Name = $Site.Name
                ApplicationPool = "$($Site.Name)"
                PhysicalPath = $Site.Path
                State = 'Started'
                DependsOn = "[xWebAppPool]$($Site.Name)AppPool"
                BindingInfo = MSFT_xWebBindingInformation
                    {
                        Protocol = 'https'
                        Port = $Site.Port
                        CertificateStoreName = 'MY'
                        CertificateThumbprint = $(Get-ChildItem cert:\LocalMachine\My | where { $_.Subject -match "WMSvc" } | select -First 1).Thumbprint
                    } 
            }
DSC配置:

    $data = @{
        AllNodes = @(
            @{
                Sites = @(
                            @{Name="website1";Port="8643";Path="C:\inetpub\www\website1";Apps="App1","App2"},                            @{Name="website2";Port="9643";Path="C:\inetpub\www\website2";Apps="App3","App4"})
    })
    }

在DSC配置中脚本资源之外使用的表达式在编译时执行。以下行将在管理计算机上执行,其中可能不存在证书,并将.mof文件中的指纹设置为
NULL
。您可以通过查看生成的mof文件来验证这一点

CertificateThumbprint = $(Get-ChildItem cert:\LocalMachine\My | where { $_.Subject -match "WMSvc" } | select -First 1).Thumbprint

您需要将指纹指定为字符串值,或者使用脚本资源设置绑定,在该绑定中,您可以将
Get ChildItem
-命令作为SetScript脚本块的一部分运行。

如果只添加一个https站点,会发生什么情况?仍然是相同的问题。看起来xwebsite不支持证书指纹处的get命令。如果我以字符串形式输入证书指纹,它可以正常工作。基本上,我们无法动态传递值。您可以将其设置为更高的变量,然后将其作为stringHey Frode传递,谢谢你的回复。我试着按照你的建议做了,但仍然是同一个问题。GetScript={}TestScript={$False}SetScript={$certificatestore=$(Get ChildItem certificatestore:\LocalMachine\My | where{$\ Subject-match“WMSvc”}选择-First 1)写主机“This is$certificatestore”}}在bindinginfo中,我正在尝试这个CertificateThumbprint=“$($certificatestore.Thumbprint)”…但仍然是同一个问题..这是你建议的吗?错误:所需的网站绑定对websiteNo无效,请在setscript中使用适当的cmdlet添加绑定(请记住也要设置有效的testscript和getscript)。如果无法为指纹AFAIK指定静态值,则无法使用xWebsite设置bindinginfo。感谢您的回答,它帮助我了解,当我尝试使用Powershell查询获取证书使用者名称时,它不会在节点本身上解析,而是使用配置数据变量来构建所需的字符串。