简体   繁体   English

获取证书到期日期 powershell

[英]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.我需要“监控”一个特定的证书过期时间,并且喜欢它在过期之前通知(电子邮件)30 天,直到它更新。

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.但是如果低于 30,我怎么能得到剩余的天数。

Any comment or helps is always appreciate it.任何评论或帮助总是很感激。

Fixitrod gives the right answer. Fixitrod 给出了正确的答案。 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 | get-childitem -path 证书:-recurse -Expiringindays 30 | Select-Object Issuer, NotAfter, Subject, FriendlyName | Select-Object Issuer、NotAfter、Subject、FriendlyName | FL FL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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