Reputation: 9625
Powershell provides access to the certificates on a windows 7 machine in the following way:
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
Now I want to iterate over the cert folder using the following pseudocode:
for each subfolder in cert:
for each certstore in subfolder:
for each cert in certstore:
print cert.information
How would I do that in powershell?
Upvotes: 2
Views: 1027
Reputation: 988
The certificate repository is covered by a PSProvider
that lets you treat it somewhat like a file system. There are providers also for the registry, wsman settings, and others.
For your purpose:
Get-ChildItem -Recurse -Path Cert:\
You can see other available providers with Get-PSProvider
. https://technet.microsoft.com/en-us/library/ee176857.aspx
Upvotes: 4