2011-09-20 24 views
3

我想从我的系统中获取所有证书。 所以我用了System.Security.Cryptography.X509Certificates class. 当我删除了()X509Store后,我得到了相同的结果就像我进入"My"PowerShell - X509Certificates.X509Store获取所有证书?

什么是看到所有的证书正确成员名称?有可能的?

MSDN StoreName Enumeration

$store=new-object System.Security.Cryptography.X509Certificates.X509Store("CA") 
# Put in CA, My, root etc. 
$store.open("ReadOnly") 
$store.Certificates 
$store.Certificates.count 

回答

6

您可以从本地证书驱动让他们:

Get-ChildItem Cert:\CurrentUser\CA # user certs 

Get-ChildItem Cert:\LocalMachine\CA # machine certs 
0

GET-ChildItem证书:\ LOCALMACHINE \我

这是乐趣,如果你有WinRM的安装但以更加标准的方式查找所有证书,使用类似

$店=新物体System.Security.Cryptography.X509Certificates.X509Store( “\ $服务器名称\我的”, “LOCALMACHINE”)

$ store.Open( “只读”)
$ store.Certificates