Home » PowerShell » Get Certificate Serial Number in PowerShell

Get Certificate Serial Number in PowerShell

The certificate has a SerialNumber property that is used to get the certificate serial number in PowerShell. It returns the string type value.

SerialNumber                    Property       string SerialNumber {get;}

Use the Get-Member cmdlet on the certificate object to get properties associated with the certificate.

In this article, we will discuss how to get a certificate serial number in PowerShell using the SerialNumber property.

Find Certificate Serial Number in PowerShell

In PowerShell, use the Get-ChildItem cmdlet to get the certificate from LocalMachine\My certificate store and use the SerialNumber property to obtain the serial number.

Run the following PowerShell script to get the certificate serial number.

Get-ChildItem -Path Cert:\LocalMachine\My\ | Select Thumbprint,SerialNumber,NotAfter

In the above PowerShell script, the Get-ChildItem cmdlet uses the Path parameter to specify the certificate store path LocalMachine\My and get all certificates. It passes the result to the Select command to display Thumbprint, certificate serial number, and certificate expiration date.

The output of the above PowerShell script to find the certificate serial number is:

Get Certificate Serial Number in PowerShell
Get Certificate Serial Number in PowerShell

Conclusion

I hope the above article on how to get a certificate serial number using the PowerShell Get-ChildItem cmdlet with a combination of SerialNumber property is helpful to you.

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