2024-04-26

Get Web Site SSL Certificate Expired Date

 $Uri = 'https://www.contoso.com';

$request = [System.Net.WebRequest]::Create($Uri);
$request.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$response = $request.GetResponse();
(($request.ServicePoint).Certificate).GetExpirationDateString();

其中 ($request.ServicePoint).Certificate.Subject 可以核對 FQDN

參考資料: https://stackoverflow.com/questions/22233702/how-to-download-the-ssl-certificate-from-a-website-using-powershell