Skip to content

Instantly share code, notes, and snippets.

@Apoc70
Created October 25, 2023 13:28
Show Gist options
  • Save Apoc70/71d94d7d1c8facfb8df5cc1e32a49acd to your computer and use it in GitHub Desktop.
Save Apoc70/71d94d7d1c8facfb8df5cc1e32a49acd to your computer and use it in GitHub Desktop.
Query the current IIS SSL Bindings and provide the IIS Site and bound certificate as output
# Original source: https://techstronghold.com/scripting/@rudolfvesely/powershell-script-to-get-all-iis-bindings-and-ssl-certificates/
# Updated the script for a sorted output on Exchange Servers
Import-Module -Name WebAdministration
Get-ChildItem -Path IIS:SSLBindings | Sort-Object Port | ForEach-Object -Process `
{
if ($_.Sites)
{
$certificate = Get-ChildItem -Path CERT:LocalMachine/My |
Where-Object -Property Thumbprint -EQ -Value $_.Thumbprint
[PsCustomObject]@{
Sites = $_.Sites.Value
CertificateFriendlyName = $certificate.FriendlyName
CertificateDnsNameList = $certificate.DnsNameList
CertificateNotAfter = $certificate.NotAfter
CertificateIssuer = $certificate.Issuer
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment