<# .SYNOPSIS CertificateReport.ps1 - Exchange Server 2010 SSL Certificate Report Script .DESCRIPTION Generates a report of the SSL certificates installed on Exchange Server 2010 servers .OUTPUTS Outputs to a HTML file. .EXAMPLE .\CertificateReport.ps1 Reports SSL certificates for Exchange Server 2010 servers and outputs to a HTML file. .LINK http://exchangeserverpro.com/powershell-script-ssl-certificate-report .NOTES Written By: Paul Cunningham Website: http://exchangeserverpro.com Twitter: http://twitter.com/exchservpro Change Log V1.00, 13/03/2014 - Initial Version V1.01, 13/03/2014 - Minor bug fix #> $myDir = Split-Path -Parent $MyInvocation.MyCommand.Path $reportfile = "$myDir\CertificateReport.html" $htmlreport = @() $exchangeservers = @(Get-ExchangeServer) foreach ($server in $exchangeservers) { $htmlsegment = @() $serverdetails = "Server: $($server.Name) ($($server.ServerRole))" Write-Host $serverdetails $certificates = @(Get-ExchangeCertificate -Server $server) $certtable = @() foreach ($cert in $certificates) { $iis = $null $smtp = $null $pop = $null $imap = $null $um = $null $subject = ((($cert.Subject -split ",")[0]) -split "=")[1] if ($($cert.IsSelfSigned)) { $selfsigned = "Yes" } else { $selfsigned = "No" } $issuer = ((($cert.Issuer -split ",")[0]) -split "=")[1] #$domains = @($cert | Select -ExpandProperty:CertificateDomains) $certdomains = @($cert | Select -ExpandProperty:CertificateDomains) if ($($certdomains.Count) -gt 1) { $domains = $null $domains = $certdomains -join ", " } else { $domains = $certdomains[0] } #$services = @($cert | Select -ExpandProperty:Services) $services = $cert.ServicesStringForm.ToCharArray() if ($services -icontains "W") {$iis = "Yes"} if ($services -icontains "S") {$smtp = "Yes"} if ($services -icontains "P") {$pop = "Yes"} if ($services -icontains "I") {$imap = "Yes"} if ($services -icontains "U") {$um = "Yes"} $certObj = New-Object PSObject $certObj | Add-Member NoteProperty -Name "Subject" -Value $subject $certObj | Add-Member NoteProperty -Name "Status" -Value $cert.Status $certObj | Add-Member NoteProperty -Name "Expires" -Value $cert.NotAfter.ToShortDateString() $certObj | Add-Member NoteProperty -Name "Self Signed" -Value $selfsigned $certObj | Add-Member NoteProperty -Name "Issuer" -Value $issuer $certObj | Add-Member NoteProperty -Name "SMTP" -Value $smtp $certObj | Add-Member NoteProperty -Name "IIS" -Value $iis $certObj | Add-Member NoteProperty -Name "POP" -Value $pop $certObj | Add-Member NoteProperty -Name "IMAP" -Value $imap $certObj | Add-Member NoteProperty -Name "UM" -Value $um $certObj | Add-Member NoteProperty -Name "Thumbprint" -Value $cert.Thumbprint $certObj | Add-Member NoteProperty -Name "Domains" -Value $domains $certtable += $certObj } $htmlcerttable = $certtable | ConvertTo-Html -Fragment $htmlserver = "

$serverdetails

" + $htmlcerttable $htmlreport += $htmlserver } $htmlhead="

Exchange Server 2010 Certificate Report

" $htmltail = " " $htmlreport = $htmlhead + $htmlreport + $htmltail $htmlreport | Out-File -Encoding utf8 -FilePath $reportfile