Как поменять сертификаты на iis для всех сайтов с помощью powershell.
Задача переставить сертификат на всех сайтах так как заканчивается срок.
Экспортируем сертификат в IIS.
После этого получаем хеш сертификата
Get-ChildItem -path cert:\LocalMachine\My
$OLDCertificateThumbprint = "вставляем Thumbprint " # старый сертификат
$NEWCertificateThumbprint = "вставляем Thumbprint " # новый сертификат
#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 … Читать далее 


