2017-08-28 2 views
-1

J'ai quelques certificats sur Windows. Ces certs ont différents modèles.Comment puis-je supprimer un certificat avec un modèle spécifique?

Je peux obtenir: l'empreinte du pouce

$Certificates = get-childitem cert:\LocalMachine\My 

Je peux obtenir des modèles:

$Template = ($Certificates.extensions | where-object{$_.oid.FriendlyName -match "Certificate Template Information"}).format(0) 

Je veux automatiser la suppression de cert qui a modèle spécifique selon thumbprint avec Powershell.

Répondre

0

Enveloppez dans un filtre Where-Object:

Get-ChildItem cert:\my\ |Where-Object{ 
    ($TmplExt = $_.Extensions |Where-Object { 
    $_.Oid.FriendlyName -match 'Certificate Template' 
    }) -and 
    $TmplExt.format(0) -match 'MyTemplateName' 
} |Remove-Item