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回答 –