Use PowerShell to Find and Display a Certificate

Need to get information on a certificate from the command line? This article has some great info on doing that with PowerShell. Here are  couple that I’ve adapted:

List details on a certificate by thumbprint:

dir cert: -Recurse | Where-Object { $_.Thumbprint -like "*0563B8630D62D75ABBC8AB1E4B*" } | fl *

List certificates that will expire between now and one year from now:

dir cert: -Recurse | Where-Object { $_.NotAfter -ge (Get-Date) -and $_.NotAfter -le (Get-Date).AddYears(1) } | fl *

You can also use the “dir” command to navigate the cert: drive, then when you find the certificate you’re interested in, pipe “Format-List” to get details. This can be run directly from a Windows command prompt:

powershell.exe "dir cert:"
powershell.exe "dir cert:\LocalMachine"
powershell.exe "dir cert:\LocalMachine\My"
powershell.exe "dir cert:\LocalMachine\My\0563B8630D62D75ABBC8AB1E4B | format-list"

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.