Issue when setting IIS binding certificate in Powershell
It turns out I was having the same problem as described here (RebindSslCertificate
the certificate is just the same as removing it and then calling AddSslCertificate
). When copying the thumbprint from the certificate dialog in Windows for some stupid reason it inserts a zero-width LTR character at the beginning of the string so my thumbprint was invalid. I added a check for this at the beginning of my script to prevent it:
if ($OldCertThumbprint -match "[\W-[\ ]]") { Write-Host "Old cert thumbprint contains non-word characters, maybe a zero-width LTR Unicode character at the beginning. You almost certainly don't want this! Aborting!" Exit}if ($ReplacementCertThumbprint -match "[\W-[\ ]]") { Write-Host "Replacement cert thumbprint contains non-word characters, maybe a zero-width LTR Unicode character at the beginning. You almost certainly don't want this! Aborting!" Exit}