PowerShell to Remove IIS Certificates

We were using this PowerShell syntax on a Windows Server Core where IIS Manager (inetmgr.exe) is not available.  Nonetheless this is handy syntax for any Window server where you might be upgrading from an older version of the LetsEncrypt client to WACS.

Objective:

Delete all existing IIS Certificates and then regenerate new ones with a current version of WACS.

How to See your Certificates

Import-Module WebAdministration 
Get-ChildItem IIS:SSLBindings
  

$cert = Get-ChildItem cert:\localmachine\WebHosting
Write-Host $cert

If you have 1 certificate, you will see the Subject, Issuer, Serial Number, Not Before, Not After and Thumbprint properties.  

Or just type
$cert

and PowerShell outputs a little table with Thumbprint and Subject. 

Note that some people may need to look in other corners for their certificates such as 

$cert = Get-ChildItem cert:\localmachine\My 

Once you are confident that $cert contains certificates to be DELETED, you can then iterate thru all and make them disappear.

How to Delete All Certificates in the $Cert variable

$cert | Remove-Item

For assistance, you can reach us at www.href.com/contact.  If this info was helpful to you, consider buying something slightly more expensive than usual from your local fresh food or coffee vendor. Keep small business alive in 2020 !  Pass it forward.







Comments

Popular Posts