How to Delete Certificate From Computer Store Using PowerShell

Rohan Timalsina Feb 16, 2024
How to Delete Certificate From Computer Store Using PowerShell

In Windows operating systems, a certificate is stored locally on the computer in a certificate store. It contains various certificates issued by different certification authorities.

PowerShell allows you to find, add, and delete certificates and certificate stores on the computer. This tutorial will teach you to remove a certificate from the certificate store with PowerShell.

Use Remove-Item Cmdlet to Delete Certificate From the Computer in PowerShell

The certificates are stored in the computer’s Cert: drive. You can use the Get-ChildItem to view the content of the certificate drive.

Get-ChildItem Cert:

Output:

Location   : CurrentUser
StoreNames : {SmartCardRoot, Root, Trust, AuthRoot...}

Location   : LocalMachine
StoreNames : {TestSignRoot, ClientAuthIssuer, OemEsim, Remote Desktop...}

The following example displays the certificate stores in the location Cert:\LocalMachine.

Get-ChildItem Cert:\LocalMachine

Output:

find the certificate stores using powershell

The following command gets the certificates in the location Cert:\LocalMachine\My.

Get-ChildItem Cert:\LocalMachine\My

Output:

Thumbprint                                Subject
----------                                -------
44D46A6187F9CD61FA958A580B7D4088650AE3FA  CN=NVIDIA GameStream Server
0751530261173474BDAB820A9868BE7BD9D92E75  CN=F900CAE78D90FFE5

You can use the Remove-Item cmdlet to delete the specified certificates from the computer. It is a handy tool that can remove different types of items, such as files, directories, variables, registry keys, functions, and aliases.

This command deletes a certificate from the My certificate store.

Remove-Item Cert:\LocalMachine\My\0751530261173474BDAB820A9868BE7BD9D92E75

It does not affect the private key. You must use the -DeleteKey parameter to delete the private key and a certificate.

Remove-Item Cert:\LocalMachine\My\0751530261173474BDAB820A9868BE7BD9D92E75 -DeleteKey

Now you should know how to delete certificates from the certificate store on your computer. For more information, see about_Certificate_Provider.

Rohan Timalsina avatar Rohan Timalsina avatar

Rohan is a learner, problem solver, and web developer. He loves to write and share his understanding.

LinkedIn Website

Related Article - PowerShell Certificate