Checking certificates expiration using Powershell

As the usage of signed certificates grows, the need for an automated way to check them grows as well.

Its not nice to discover your vCenter is disconnected from everything just because you forgot to renew its certificate.

Luckily, its quite easy to script it using powershell:

$urls = @(‘https://www.google.com’,’https://www.yahoo.com’,etc…)

foreach ($url in $urls )

{

$req = [Net.HttpWebRequest]::Create($url)

$req.GetResponse() | out-null

$expiration = $req.ServicePoint.Certificate.GetExpirationDateString()

$url, $expiration

}

This will print each website with its expiration date, you can also use ports , if the server have more then one certificate installed on it.

Advertisements
Tagged , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: