以下代码是我用来从当前用户商店中删除证书的代码:
#Delete Certificates
$certs = Get-ChildItem cert:\CurrentUser\My | where { $_.IssuerName.Name -like '*CN=Issuer*' }
foreach ($cert in $certs) {
$store = Get-Item $cert.PSParentPath -Force
$store.Open('ReadWrite')
$store.Remove($cert)
$store.Close()
}
我想知道是否有办法将此代码修改为将在计算机上的所有用户帐户上删除此证书的位置。例如,如果我在User1上运行它,它将删除User1和User2上的证书。我已经研究过这个,但是在访问其他用户证书商店方面却找不到任何东西。任何帮助表示赞赏。如果您需要更多信息,请告诉我。
答案 0 :(得分:1)
由于用户的证书存储区保存在其注册表配置单元中,因此不能轻易使用。这意味着,为了访问未登录的用户证书存储区,您必须首先加载其注册表配置单元,然后逐个manually decode their certificate blobs找到您要查找的证书。不建议这样做。
可能更好的解决方案是将脚本设置为在每个用户通过组策略或其他类似用户登录时运行。