簡體   English   中英

綁定后將SSL證書分配給網站-Powershell

[英]Assign SSL Certificate to Website After Binding - Powershell

美好的一天。 與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

假設您的證書位於cert: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-configuration-ssl

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM