小编Xyz*_*Xyz的帖子

电源外壳。循环遍历证书存储并根据指纹删除证书

我有一个通过 GPO 启动脚本运行的简单 powershell 脚本。如您所见,它会在证书存储中循环获取指纹,并在找到它时将其删除。

#thumbprint of certificate to remove
$thumb = "abcdef444444857694df5e45b68851868"

#loop through all the certs stores looking for $thumb and remove if found
get-childitem Cert:/ -recurse | where-object {$_.thumbprint -contains "$thumb"} | remove-item

Run Code Online (Sandbox Code Playgroud)

当我从提升的 powershell 提示符运行上面两行时,它起作用了

如果我重新启动计算机并让 GPO 执行此操作,或者如果我从提升的 powershell 运行,则会出现以下提示:

powershell.exe -Noninteractive -ExecutionPolicy Bypass -Noprofile -file "\\mydomain.corp\SysVol\mydomain.corp\Policies\{7086C68E-D509-9169-A02B-56579826C234}\Machine\Scripts\Startup\removecerts.ps1"
Run Code Online (Sandbox Code Playgroud)

然后我得到以下信息:

remove-item :该操作针对用户根存储,并且不允许 UI。

任何帮助,将不胜感激。

powershell certificate

5
推荐指数
1
解决办法
2599
查看次数

标签 统计

certificate ×1

powershell ×1