Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 如何删除具有特定模板的证书?_Powershell_Certificate - Fatal编程技术网

Powershell 如何删除具有特定模板的证书?

Powershell 如何删除具有特定模板的证书?,powershell,certificate,Powershell,Certificate,我在Windows上有一些证书。这些证书有不同的模板 我可以得到指纹: $Certificates = get-childitem cert:\LocalMachine\My 我可以获得模板: $Template = ($Certificates.extensions | where-object{$_.oid.FriendlyName -match "Certificate Template Information"}).format(0) 因此,我想使用powershell根据指纹自动删

我在Windows上有一些证书。这些证书有不同的模板

我可以得到指纹:

$Certificates = get-childitem cert:\LocalMachine\My
我可以获得模板:

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

因此,我想使用powershell根据指纹自动删除具有特定模板的证书。

将其包装在
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