Возможно, сделав, как показано ниже, вы получите формат, который вам нужен:
$CertPath = 'Cert:\LocalMachine\' #'# dummy comment to correct code-highlighting in SO
$CertsDetail = Get-ChildItem -Path $CertPath -Recurse | Where-Object { !$_.PsIsContainer } | ForEach-Object {
$Usages = ($_.Extensions | Where-Object {$_.KeyUsages}).KeyUsages
if ($Usages) {
# get at most two parts out of the $_.Issuer string
$issuer = '{0}, {1}' -f ([regex] 'O=([^,]+)').Match($_.Issuer).Groups[1].Value,
([regex] 'CN=([^,]+)').Match($_.Issuer).Groups[1].Value
[PSCustomObject]@{
Issuer = $issuer.Trim(", ")
Subject = $_.Subject
Usages = $Usages.ToString() -replace ',', ';'
}
}
}
$CertsDetail | Format-List
$CertsDetail | Export-Csv -NoTypeInformation -Path 'C:\SECnology\Data\Utilities\Certificate_State.csv'
Попытка сделать это на моем (Windows 7) компьютере дает мне вывод, как
Issuer : Microsoft Root Authority
Subject : CN=Microsoft Enforced Licensing Intermediate PCA, OU=Copyright (c) 1999 Microsoft Corp., O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Usages : CrlSign; KeyCertSign; DigitalSignature
Issuer : The USERTRUST Network, UTN-USERFirst-Hardware
Subject : CN=www.google.com, OU=PlatinumSSL, OU=Hosted by GTI Group Corporation, OU=Tech Dept., O=Google Ltd., STREET=Sea Village 10, L=English, S=Florida, PostalCode=38477, C=US
Usages : KeyEncipherment; DigitalSignature