Skip to content

Instantly share code, notes, and snippets.

@stack72
Created April 17, 2014 19:28
Show Gist options
  • Save stack72/11006439 to your computer and use it in GitHub Desktop.
Save stack72/11006439 to your computer and use it in GitHub Desktop.
Import-Module WebAdministration;
$ip = '0.0.0.0'
$port = 443
$sitename = ""
$certificate = ""
if((Test-Path IIS:\SslBindings\$ip!$port) -eq $true) {
$site = Get-Website | Where-Object { $_.Name -eq "$sitename" }
$certsAttachedToSite = Get-ChildItem IIS:\SSLBindings | ? { $site | Select-Object { $_ -contains $_.Sites.Value }} | % { $_.Thumbprint }
$certificate = Get-ChildItem CERT:\LocalMachine\My | ? { $certsAttachedToSite -contains $_.Thumbprint} | Where-Object { $_.Thumbprint -eq "$certificate" }
if ($certificate -ne $null ){
Write-Host "Certificate needs changed"
}
else {
"We have the correct certificate"
}
}
else {
Write-Host "No Binding exists"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment