...
Run the following commands to replace the certificate:
Info The commands below are optional and will alert most Windows applications that an old certificate has been replaced by a new one. Only applications that subscribe to certificate notifications will be affected by these commands
Code Block $cert_match = Get-ChildItem -Path $cert_folder | Where-Object {$_.Subject -eq $cert_object.Subject -and $_.Issuer -eq $cert_object.Issuer } | Sort-Object -Property NotBefore -Descending If ($cert_match.Count -eq 2) { Try { Switch-Certificate -OldCert $cert_match[1] -NewCert $cert_match[0] } Catch { Write-Host "Error replacing certificate" } } If ($cert_match.Count -gt 2) { Write-Host "Too many matching certificate; reduce matching certificate count to 2"; $cert_match | Select-Object Thumbprint, HasPrivateKey, NotBefore, NotAfter, Subject, Issuer } If ($cert_match.Count -lt 2) { Write-Host "Only one matching certificate; review certificates and service config"; $cert_match | Select-Object Thumbprint, HasPrivateKey, NotBefore, NotAfter, Subject, Issuer }Run the following commands to remove the previous certificate
Code Block If ($cert_match.Count -eq 2) { Try { Remove-Item $cert_match[1] } Catch { Write-Host "Error removing certificate" } }
...