This powershell function will grab the SSL certificate from a website, make the name, issuer and ExpirationDate a little more accessible and return it.
[code]
function Get-WebCertificate (){
[cmdletbinding()]
param(
[parameter(ValueFromPipelineByPropertyName,ValueFromPipeline)]
[string]$Name
)
process {
if ($Name -notlike 'https://*') {
$Name = "https://$Name"
}
Write-Host $Name
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$req = [Net.HttpWebRequest]::Create($Name)
if ($req) {
$req.Timeout = 5000
try {$req.GetResponse()} catch {}
$certificate = $req.ServicePoint.Certificate
}
if ($certificate) {
$certificate | %{ New-Object -TypeName PSObject -Prop @{'Name'=$Name; 'Issuer'=$certificate.Issuer; 'ExpirationDate'=$certificate.GetExpirationDateString(); 'Subject'=$certificate.Subject } }
}
}
}
[/code]