Home » PowerShell » Find Certificate by Thumbprint in PowerShell

Find Certificate by Thumbprint in PowerShell

The certificate has a Thumbprint property which is used as a unique identifier. Using the Get-ChildItem cmdlet in PowerShell in combination with the Where-Object cmdlet can find a certificate by thumbprint.

Where-Object cmdlet in PowerShell to filter the results and retrieve the certificate by a thumbprint.

In this article, we will discuss how to find a certificate by certificate using the Get-ChildItem cmdlet in PowerShell.

Get Certificate by Thumbprint in PowerShell

Use the Thumbprint property of a certificate to find a certificate that matches the thumbprint of a certificate using the -eq operator.

Run the following command to obtain the certificate by Thumbprint.

Get-ChildItem -Path 'cert:\LocalMachine\My' | Where-Object { $_.Thumbprint -eq '984E459FF99D87FD97AFC46DCDCBCB90E0B7FCD5' } | Select Thumbprint,Subject,NotAfter,FriendlyName 

In the above PowerShell script, the Get-ChildItem cmdlet uses the Path parameter to specify the LocalMachine\My certificate store location path to retrieve the certificates.

It passes all the certificates to the Where-Object cmdlet to check if the thumbprint of a certificate is equal to provided fingerprint. On successful match of a thumbprint, it gets a certificate thumbprint, Subject, FriendlyName, and expiration date of certification.

The output of the above PowerShell script to find the certificate by thumbprint is:

PowerShell Find Certificate by Thumbprint
PowerShell Find Certificate by Thumbprint

Conclusion

I hope the above article on how to find a certificate by thumbprint using the Get-ChildItem cmdlet in PowerShell is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.