You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用PowerShell筛选出仅用于Server Authentication的最新证书

筛选仅含Server Authentication的最新证书

你的原命令会匹配所有包含Server Authentication用途的证书,包括同时带有Remote Desktop Authentication等其他用途的。要筛选仅用于Server Authentication的证书,需要同时检查增强密钥用途列表的条目数量和具体内容:

修正后的命令

Get-ChildItem -Recurse Cert:\LocalMachine\My | 
    Where-Object {
        # 确保增强密钥用途只有1项,且该项是Server Authentication
        $_.EnhancedKeyUsageList.Count -eq 1 -and 
        $_.EnhancedKeyUsageList.FriendlyName -eq 'Server Authentication'
    } | 
    Sort-Object NotBefore -Descending |  # 按证书创建时间倒序,取最新创建的
    Select-Object -First 1

补充说明

  • 如果你需要的是最晚到期的证书,把排序字段换成NotAfter即可:Sort-Object NotAfter -Descending
  • 可以在最后加上具体字段查看验证,比如:Select-Object Thumbprint, Subject, NotBefore, NotAfter, EnhancedKeyUsageList

内容的提问来源于stack exchange,提问作者udhayan dharmalingam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 11:22:08