Issuer 不是 ADCS 数据库模式中的列。因此,唯一的方法是获取证书本身,对其进行解析并打印出颁发者名称。
$tempFileName = "C:\Users\$env:UserName\AppData\Local\Temp\cert.cer";
& certutil -view -config "Issuing-CA01" -restrict "notbefore>22/09/2021" -out "RawCertificate" `
| Out-File -FilePath $tempFileName;
[regex]::Matches( `
(Get-Content $tempFileName), `
"-----BEGIN CERTIFICATE-----[\s\r\n]{1}" +
"(?<cert>[a-z|A-Z|0-9|\+|\-|\\|\/|\s|\r|\n|=]*)" +
"-----END CERTIFICATE-----", `
[System.Text.RegularExpressions.RegexOptions]::Multiline) `
| Foreach-Object {
[System.IO.File]::WriteAllText(`
$tempFileName, `
$_.Groups["cert"].Value.Replace(" ", ""));
$certificate = `
New-Object System.Security.Cryptography.X509Certificates.X509Certificate2(`
$tempFileName);
Write-Host $certificate.Issuer;
}
Remove-Item $tempFileName;