美好的一天。如何在绑定http和https后自动为网站分配SSL证书?
我有这个代码,它绑定了http和https,但它没有分配SSL证书。也许你可以帮助我。提前谢谢。
$thumbprint="########################################"
$binding = @{protocol="http";bindingInformation=$ip+":80:"+$iisAppNameBinding}
new-item $iisAppName -type site –physicalPath $directoryPath -bindings $binding
$newBinding = (
@{protocol="http";bindingInformation=$ip+":80:"+$iisAppNameBinding},
@{protocol="https";bindingInformation=$ip+":443:"+$iisAppNameBinding;certificateStoreName="MY";certificateName=$thumbprint})
Set-itemproperty $iisAppName -name bindings -value $newBinding
答案 0 :(得分:0)
假设您的证书位于证书:LocalMachine \ My
下import-module webadministration
$computerName = $Env:Computername
$domainName = $Env:UserDnsDomain
New-WebBinding -Name "MyWebSite" -IP "*" -Port 443 -Protocol https
Get-ChildItem cert:\LocalMachine\My | where { $_.Subject -match "CN\=$Computername\.$DomainName" } | select -First 1 | New-Item IIS:\SslBindings\0.0.0.0!443
另一种方法的参考链接:powershell-snap-in-configuring-ssl