Webinar: PKI Insights - The Most Common Misconfigurations in Today's PKI

PowerShell PKI Module Documentation

Documentation Home



Disassociates certificate from private key and deletes physical private key material.


Remove-CertificatePrivateKey [-Certificate] <X509Certificate2[]> [<CommonParameters>]


Disassociates certificate from private key and deletes physical private key material. When you delete the certificate using Certificates MMC snap-in, certutil.exe command-line tool, or use Remove-Item cmdlet against Cert:\ PSDrive, only public part of the certificate is deleted and private key material is left on a system thus giving a false sense of destroyed key. This cmdlet ensures that the private key physical material is really destroyed. A PIN prompt may appear when private key is stored on a Smart Card or Hardware Security Module (HSM).

The function returns True if certificate has associated private key and the key was deleted. The function returns False if there is no associated private key.


-Certificate <X509Certificate2[]>

Certificate object to delete private key material for.

Required? True
Position? 0
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? False


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, InformationAction, InformationVariable,
WarningAction, WarningVariable, OutBuffer, PipelineVariable and OutVariable.
For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).







Example 1

PS C:\> Get-Item Cert:\CurrentUser\My\D5643407CD9F4B9566FB6486E3B33C08713C191D | Remove-CertificatePrivateKey

Retrieves certificate with thumbprint 'D5643407CD9F4B9566FB6486E3B33C08713C191D' from currently logged on user personal store and deletes private key material.

Related links

Minimum PowerShell version support

  • Windows PowerShell 3.0

Operating System Support

  • Windows 7
  • Windows 8
  • Windows 8.1
  • Windows 10
  • Windows 11
  • Windows Server 2008 R2 all editions
  • Windows Server 2012 all editions
  • Windows Server 2012 R2 all editions
  • Windows Server 2016 all editions
  • Windows Server 2019 all editions
  • Windows Server 2022 all editions