PowerShell 技能连载 - 检查证书详细信息

如果您想检查和查看一个证书文件的详细信息而不需要将它导入证书存储空间,以下是一个简单的例子:

1
2
3
4
5
6
7
# replace path with actual path to CER file
$Path = 'C:\Path\To\CertificateFile\test.cer'

Add-Type -AssemblyName System.Security
[Security.Cryptography.X509Certificates.X509Certificate2]$cert = [Security.Cryptography.X509Certificates.X509Certificate2]::CreateFromCertFile($Path)

$cert | Select-Object -Property *

您现在可以存取所有详细信息并获取指纹或检查失效日期:

1
2
3
4
5
6
PS C:\> $cert.Thumbprint
7A5A350D95247BB173CDF0867ADA2DBFFCCABDE6

PS C:\> $cert.NotAfter

Monday June 12 2017 06:00:00

PowerShell 技能连载 - 检查证书详细信息

http://blog.vichamp.com/2017/03/31/examining-certificate-details/

作者

吴波

发布于

2017-03-31

更新于

2022-07-06

许可协议

评论