Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chaddoncooper/cc59597a4019656e3036412fe14335fc to your computer and use it in GitHub Desktop.
Save chaddoncooper/cc59597a4019656e3036412fe14335fc to your computer and use it in GitHub Desktop.
Powershell IIS remove certificate and bindings
$ConfirmPreference = 'None'
$ApiPortBinding = 443
$Subject = "SubjectName"
Get-ChildItem Cert:\localmachine\my | Where-Object { $_.Subject -match $Subject } | Remove-Item -Force
Get-ChildItem Cert:\localmachine\CA | Where-Object { $_.Subject -match $Subject } | Remove-Item -Force
Get-ChildItem Cert:\localmachine\root | Where-Object { $_.Subject -match $Subject } | Remove-Item -Force
if (-Not (netsh http show sslcert ipport=0.0.0.0:$(ApiPortBinding) | find "The system cannot find the file specified"))
{
netsh http delete sslcert ipport=0.0.0.0:$(ApiPortBinding)
}
if (-Not (netsh http show sslcert ipport=0.0.0.0:$(FrontendPortBinding) | find "The system cannot find the file specified"))
{
netsh http delete sslcert ipport=0.0.0.0:$(FrontendPortBinding)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment