Powershell: Get the certificate of a webserver

Hi,

like openssl s_client you can also use powershell to view/get the certificate of a webserver.

Try the following snipped

PS D:\> $URL="https://myWebserver.myDomain.org"
PS D:\> [System.Net.HttpWebRequest]$oHTTPRequest=[System.Net.WebRequest]::Create($URL)
PS D:\> [System.Net.HttpWebResponse]$oHttpWebResponse=$oHTTPRequest.GetResponse()
PS D:\> $oHttpWebResponse.Close()
PS D:\> [System.Security.Cryptography.X509Certificates.X509Certificate2]$oCert=$oHTTPRequest.ServicePoint.Certificate
PS D:\> $oCert | fl *

Michael

Leave a Reply