我正在尝试使用PowerShell获取所有证书。当我将"\$computer\My"设置为存储位置时,下面的脚本返回用户证书。当我将"\$computer\root"设置为存储位置时,它返回根证书。如何获取用户和机器证书?
$computer='localhost';
$ro=[System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly"
$lm=[System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine"
$store=new-object System.Security.Cryptography.X509Certificates.X509Store("\\$computer\My",$lm)
$store.Open($ro)
$certificates=$store.Certificates