[英]How to add an SSL certificate to an azure website using powershell?
[英]How to retrieve SSL certificate of an IIS website in PowerShell
我正在嘗試檢索一堆 IIS 網站的證書,並將指紋與我擁有的證書匹配。 如果指紋匹配,那很好。 但是,如果指紋不匹配,那么我想將該特定證書添加到該網站。 我知道我可以使用以下方法驗證所需的證書是否存在:
Get-ChildItem -Path Cert:\LocalMachine\My | Select-Object Thumbprint
我可以獲取 IIS 網站並使用以下方法查看綁定:
Get-ChildItem -Path IIS:Sites | Select-Object -ExpandProperty Bindings
但是,我不知道如何檢索這些網站的證書指紋。 我將目標證書的指紋存儲在一個變量中,如下所示:
$CertThumbprint = "###############################"
如果我走錯了路,請告訴我。 謝謝你。
首先,這不是我的代碼,在這里找到的。
你可以試試這個:
Import-Module WebAdministration
$siteThumbs = Get-ChildItem IIS:SSLBindings | Foreach-Object {
[PSCustomObject]@{
Site = $_.Sites.Value
Thumbprint = $_.Thumbprint
}
}
這應該為您提供一個包含站點和指紋的對象數組供您比較。
從您的評論中,我收集到多個站點可以共享相同的指紋並分別列出它們,您可以這樣做(未經測試)
Import-Module WebAdministration
$siteThumbs = Get-ChildItem IIS:SSLBindings | Foreach-Object {
$thumb = $_.Thumbprint
foreach ($site in $_.Sites.Value) {
[PSCustomObject]@{
Site = $site
Thumbprint = $thumb
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.