简体   繁体   中英

get certificate expiration date powershell

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

I need to "monitor" an specific certificate expiration and id like it to notify (email) for 30 days before it expires till its 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 bellow 30.

Any comment or helps is always appreciate it.

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
get-childitem -path cert: -recurse -Expiringindays 30

Sorry guys, i slightly modified the last command to below so i can get more info and format it in list view

get-childitem -path cert: -recurse -Expiringindays 30 | Select-Object Issuer, NotAfter, Subject, FriendlyName | FL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM