Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
How to Export a certificate from a certificate store using PowerShell?
To export or download a certificate from the certificate store using PowerShell, we need to use the command Export-Certificate.
First, you need to get the certificate details from the store. If you know the thumbprint, you can directly get the certificate details using the thumbprint and then use that details to export the certificate.
Example
$cert = (Get-ChildItem Cert:\LocalMachine\My\43E6035D120EBE9ECE8100E8F38B85A9F) Export-Certificate -Cert $cert -Type CERT -FilePath C:\Temp\Mycert.cer
In the above example, we are exporting the certificate from the LocalMachine -> Personal Store. You can choose a different path. Here, the certificate would be exported to the C:\temp\MyCert.cer.
You can use the different types like P7B, SST to export the certificate. Alternatively, you can use the below command.
Syntax
Get-ChildItem Cert:\LocalMachine\My\43E6035D120EBE9ECE8100E8F38B85A9F1C1140F ` | Export-Certificate -Type cer -FilePath C:\Temp\newcert.cer -Force
If you don't know the certificate thumbprint then you can use any of the certificate's unique properties like Subject, FriendlyName, etc to retrieve the details. For example,
Example
Get-ChildItem Cert:\LocalMachine\My\ `
| where{$_.FriendlyName -eq "mysitecert"} `
| Export-Certificate -Type cer -FilePath C:\Temp\newcert.cer -Force 