如何将IIS证书列表导出到详细列表中?
答
我找到了一个powrshell脚本。 我用notepadd ++找到&替换命令来制作一个正确的CSV。
# Get all certs in MY store of Local Machine profile
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("My","LocalMachine")
$store.Open("ReadOnly")
$store.Certificates |
% {
# Get all extensions for one cert
$cert = $_
$cert.Extensions |
% {
# Find "Enhanced Key Usage" extension
$extension = $_
If ($extension.Oid.FriendlyName -eq "Enhanced Key Usage")
{
# Get all enhanced key usages for the cert
$enhancedKeyUsageExtension = [System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension]$extension
$enhancedKeyUsageExtension.EnhancedKeyUsages |
% {
# Find "Server Authentication" enhanced key usage
$enhancedKeyUsage = $_
If ($enhancedKeyUsage.FriendlyName -eq "Server Authentication")
{
# We found a cert that will get listed in Server Certificates list in IIS Manager. Show its info
$cert | Select Subject, Issuer, NotBefore, NotAfter, Thumbprint, SerialNumber
}
}
}
}
}
$store.Close()
您可以从power shell命令行的ps1文件中运行它,并将结果保存到文件中。 这样的事: 。\ getSSL.ps1 | Out-File myfile.txt
它不受IIS的控制,但作为计算机帐户的个人证书存储区的一部分。因此,您需要了解一些查询方法,例如PowerShell或WMI。 –