Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get certificate expiration date powershell

Tags:

powershell

I'd like to get your ideas how would you get the remaining days for a certificate to expire.

I need to "monitor" a specific certificate expiration and I'd like it to notify (email) for 30 days before it expires till it's renewed.

I can look for the cert by running:

$cert = "AAAAAAAEEEEEEEFIIIIIIIIIOOOOOOOOUUUUUUUU"
Get-ChildItem -Path cert: -Recurse | where {$_.Thumbprint -eq $cert}

but how could I get the remaining days if is below 30?

Any comment or help is always appreciated.

like image 452
elmizu Avatar asked Feb 10 '26 08:02

elmizu


1 Answers

Fixitrod gives the right answer. But if somehow you want to know the exactly date that will expire, you can run the following command:

Get-ChildItem -path cert:\LocalMachine\My | Select-Object NotAfter, Subject
like image 134
Leandro Carvalho Avatar answered Feb 12 '26 21:02

Leandro Carvalho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!