0
如果符合条件,证书即被删除,但文本“The cert is being removed”未显示出来。预期写入条件在脚本中不起作用
请告知
$pc = '.'
$cert_store = 'My'
write "The is the cert store we are working with : $cert_store"
$store = New-Object system.security.cryptography.X509Certificates.X509Store ("My","LocalMachine") #LocalMachine could also be LocalUser
$store.Open('ReadWrite')
write "opening the store for editing"
## Find all certs that have an Issuer of old CA
$certs = $store.Certificates | Where { $_.Issuer -eq 'CN=DomainRootCA, DC=Corporate, DC=Local' }
if ($certs -ne $null)
{
## Remove all the certs it finds
$certs | foreach { $store.Remove($_) | write "The cert is being removed" }
}
如果更改此行$ certs | foreach {$ store.Remove($ _)|写“证书正在被删除”}到这行$ certs | foreach {$ store.Remove($ _);写“证书正在被删除”}(意思是将管道改为分号) – DVT
感谢您的建议@DVT它完美的工作! – NobleMan
@DVT回答 –