【问题标题】:Iterate over certificates in windows powershell在 windows powershell 中迭代证书
【发布时间】:2017-06-03 18:35:17
【问题描述】:

Powershell 通过以下方式提供对 Windows 7 机器上证书的访问:

  PS C:\Users\z0017fjy> cd cert:
PS cert:\> dir


Location   : CurrentUser
StoreNames : {SmartCardRoot, UserDS, AuthRoot, CA...}

Location   : LocalMachine
StoreNames : {SmartCardRoot, AuthRoot, CA, Trust...}



PS cert:\> cd .\LocalMachine
PS cert:\LocalMachine> dir


Name : SmartCardRoot

Name : AuthRoot

Name : CA

Name : Trust

Name : Disallowed

Name : SMS

Name : My

Name : Root

Name : TrustedPeople

Name : TrustedDevices

Name : Remote Desktop

Name : TrustedPublisher

Name : REQUEST

现在我想使用以下伪代码遍历 cert 文件夹:

for each subfolder in cert:
  for each certstore in subfolder:
     for each cert in certstore:
        print cert.information

我将如何在 powershell 中做到这一点?

【问题讨论】:

  • 你试过Get-ChildItem -Recurse Cert:\ 吗?
  • 我已经试过了。看起来不错!请将其作为正确答案发布,以便我接受。

标签: windows powershell certificate


【解决方案1】:

证书存储库由PSProvider 覆盖,您可以将其视为文件系统。还有注册表、wsman 设置等提供程序。

为了您的目的: Get-ChildItem -Recurse -Path Cert:\

您可以使用Get-PSProvider 查看其他可用的提供程序。 https://technet.microsoft.com/en-us/library/ee176857.aspx

【讨论】:

    猜你喜欢
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 2016-02-07
    • 2017-09-05
    • 2013-08-03
    相关资源
    最近更新 更多