Importing Multiple Certificates from PFX Files

by Feb 14, 2014

Get-PfxCertificate can import digital certificates from a PFX file. However, it can only retrieve one certificate. So if your PFX file contains more than one certificate, you cannot use this cmdlet to get the others.

To import multiple certificates from a PFX file, simply use the code below:

$pfxpath = 'C:\PathToPfxFile\testcert.pfx'
$password = 'topsecret'

Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
$cert.Import($pfxpath, $password, 'Exportable')
$cert
 

Twitter This Tip! ReTweet this Tip!