如何删除具有特定模板的证书? [英] How can I delete certificate that has specific template?

查看:123
本文介绍了如何删除具有特定模板的证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have some certificates on Windows. These certs has different templates.

我可以获得指纹:

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

我可以获取模板:

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

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

So I want to automate deleting cert that has specific template according to thumbprint with 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 

这篇关于如何删除具有特定模板的证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆