在 windows powershell 中迭代证书
Iterate over certificates in windows powershell
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
现在我想使用以下伪代码遍历证书文件夹:
for each subfolder in cert:
for each certstore in subfolder:
for each cert in certstore:
print cert.information
我将如何在 powershell 中执行此操作?
证书存储库包含在 PSProvider
中,使您可以将其视为一个文件系统。还有用于注册表、wsman 设置等的提供程序。
为了您的目的:
Get-ChildItem -Recurse -Path Cert:\
您可以通过 Get-PSProvider
查看其他可用的提供商。 https://technet.microsoft.com/en-us/library/ee176857.aspx
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
现在我想使用以下伪代码遍历证书文件夹:
for each subfolder in cert:
for each certstore in subfolder:
for each cert in certstore:
print cert.information
我将如何在 powershell 中执行此操作?
证书存储库包含在 PSProvider
中,使您可以将其视为一个文件系统。还有用于注册表、wsman 设置等的提供程序。
为了您的目的:
Get-ChildItem -Recurse -Path Cert:\
您可以通过 Get-PSProvider
查看其他可用的提供商。 https://technet.microsoft.com/en-us/library/ee176857.aspx