Check SSL Expiratio...
 
Notifications
Clear all

Check SSL Expiration date for websites

Raju
 Raju
(@raju)
Member Admin

Check SSL Expiration date for websites

$exhosts = @("h1bsalary.online", "h1bsalary.org")
$warning_days = 360

foreach ($exhost in $exhosts) {
# Get SSL certificate expiration date
$cert = [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};
$http = [System.Net.WebRequest]::Create("https://$exhost")
$http.GetResponse();
$cert = $http.ServicePoint.Certificate;
$expiration_date = $cert.GetExpirationDateString();

# Calculate number of days until expiration
$time_until_expiration = New-TimeSpan -Start (Get-Date) -End $expiration_date;
$days_until_expiration = $time_until_expiration.Days;

# If expiration date is within warning period, print alert message
if ($days_until_expiration -le $warning_days) {
    Write-Host "$exhost SSL certificate expires in $days_until_expiration days. Please renew as soon as possible."
}

} 
 

 

This topic was modified 2 years ago by Raju
Quote
Topic starter Posted : 04/12/2022 9:46 pm
Topic Tags
Share: