用 PowerShell 浏览 Windows 证书存储(Cert: 驱动器)

把 Windows 证书存储当文件系统用:列出证书、按到期时间排序,提前找出快过期的证书。

Windows证书安全PowerShell低风险
运行 `Get-ChildItem Cert:\LocalMachine\My | Select-Object Subject, NotAfter` 即可列出本机证书及其到期时间。

01命令

命令
$ Get-ChildItem Cert:\LocalMachine\My | Select-Object Subject, NotAfter, Thumbprint

02作用说明

PowerShell 把证书存储暴露为一个驱动器:Cert:\CurrentUser\My、Cert:\LocalMachine\Root 等就像文件夹,普通的 Get-ChildItem / Where-Object 管道直接可用。最实用的场景是到期监控:`... | Where-Object NotAfter -lt (Get-Date).AddDays(30)` 能找出一个月内会过期的证书。每个对象还带 Thumbprint(指纹),续期或删除证书时都需要它。

03风险

风险低风险
使用条件Reading LocalMachine stores may require elevation; CurrentUser\My works without it.

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • Get-PfxCertificate | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    依据: Microsoft documents the Certificate provider and Cert: drive, letting PowerShell navigate certificate stores and read certificate objects such as NotAfter.
  • Get-ChildItem | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    依据: Microsoft documents Get-ChildItem as the cmdlet for enumerating items at any provider path, including the Cert: certificate store drive.

最后验证: 2026-09-17 · 分类: 安全与隐私

06相关方案