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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.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 如何获取即将过期的受信任toot证书(60天)_Powershell_Shell_Certificate_Windows Server 2012 R2_Script - Fatal编程技术网

Powershell 如何获取即将过期的受信任toot证书(60天)

Powershell 如何获取即将过期的受信任toot证书(60天),powershell,shell,certificate,windows-server-2012-r2,script,Powershell,Shell,Certificate,Windows Server 2012 R2,Script,我正在尝试获取将在60天后过期的受信任根证书。这就是我目前所拥有的 $getcert=Get-ChildItem -Path Cert:\LocalMachine\AuthRoot -ExpiringInDays 60 foreach ($cert in $getcert) { $cert.issuer #how to get this? if($cert -ne "" -and $cert.issuer -notcontains "Root CA"

我正在尝试获取将在60天后过期的受信任根证书。这就是我目前所拥有的

$getcert=Get-ChildItem -Path Cert:\LocalMachine\AuthRoot -ExpiringInDays 60
foreach ($cert in $getcert) {  

$cert.issuer #how to get this?

if($cert -ne "" -and $cert.issuer -notcontains "Root CA" ){

"send notification"
$cert.FriendlyName

}else{

"continue"
}}
但我无法获取颁发者,我需要它以排除根CA或服务器创建的颁发者,这样我就可以知道Digicert之类的证书何时过期,然后发送通知(已经配置了mailgun,无需添加此部分)

MMC中有一个“颁发者”属性,但不知道如何通过PS找到它,有人能帮我吗?非常感谢您的帮助


谢谢,致以最诚挚的问候。

继续我的评论,您可以筛选管道连接到
Where对象的非“根CA”证书,除非这不是全部筛选目的。因此,您可以这样做:

$Expriring_Certs = Get-ChildItem -Path Cert:\LocalMachine\AuthRoot  -ExpiringInDays 60 | Where-Object {$_.Subject -notmatch  "Root CA"}
    foreach($Cert in $Expriring_Certs){
        [PSCustomObject]@{
            "Friendly Name"   = $Cert.FriendlyName
            "  Cert Issuer  " = $Cert.Issuer
            "Expiration Date" = $Cert.NotAfter
            
        }
    }

将证书保存在变量中后,您可以执行
$getcert[0]|选择*
并查看自己的属性名称和值。你应该在那里找到你要找的。你也可以在你的
Get ChildItem
中对非“Root CA”进行筛选。谢谢,这正是我需要的!