Austin Certificates - How-To - Replace Windows certificates

Austin Certificates - How-To - Replace Windows certificates

Prerequisites

  • A replacement certificate has been installed for an existing certificate

  • The replacement and existing certificate have the same subject

Retrieve the certificates

  1. Sign in to the computer where the certificates are installed then start an administrative PowerShell session

  2. Run the following commands to define the certificates to be updated: 

    $Subject = Read-Host -Prompt "Provide the subject of the certificate to be updated"
  3. Run the following commands to define the certificate store:

    $CertStoreLocation = 'Cert:\LocalMachine\My'
  4. Run the following commands to retrieve the certificates to be updated:

    $Certificates = Get-ChildItem -Path $CertStoreLocation | Where-Object { $_.Subject -eq $Subject } | Sort-Object -Property NotBefore

Update the certificate

  1. Run the following commands to replace the certificate: 

    Switch-Certificate -OldCert $Certificates[-2] -NewCert $Certificates[-1]