close

多台伺服器要更新
想偷懶只好使用 Powershell 來偷懶

Updating IIS certificates with powershell

 

$OLDCertificateThumbprint = "123456789abcdefgh1a2b3c4d5e6f7g8h9a1a1a1"
$NEWCertificateThumbprint = "7a3b5a1g1a6a2j2a262a3343a333a5a64a4a4a4a"

#Show bindings where the old certificate is in use
Get-WebBinding | Where-Object { $_.certificateHash -eq $OLDCertificateThumbprint} | Format-Table

#Select bindings where the old certificate is in use and attach the new certificate
Get-WebBinding | Where-Object { $_.certificateHash -eq $OLDCertificateThumbprint} | ForEach-Object {
        Write-Host "Working on"  $_ 
        $_.RemoveSslCertificate()
        $_.AddSslCertificate($NEWCertificateThumbprint, 'My')
        }

#Show bindings where the new certificate is in use
Get-WebBinding | Where-Object { $_.certificateHash -eq $NEWCertificateThumbprint}

 

GOOGLE 測試貌似可以用

參考連結 : 

Updating IIS certificates with powershell (lachlanbarclay.net)
powershell - Update all bindings in IIS to replace an expiring SSL Certificate with a new one - Stack Overflow
Simple PowerShell Script To Update SSL Certificate Bindings On All IIS Sites ~ Bauer-Power Media (archive.org)
IIS - Install SSL Certificate via Shell or Prompt (xolphin.com)

 


arrow
arrow
    文章標籤
    powershell
    全站熱搜
    創作者介紹
    創作者 sungshu 的頭像
    sungshu

    sungshu手札筆記本

    sungshu 發表在 痞客邦 留言(1) 人氣()