Directly Importing Certificates (Part 2)

In the previous tip we showed how to import digital certificates with .NET methods on any version of PowerShell. Newer versions of PowerShell come with the “PKI” module which includes the cmdlet Import-Certificate. With it, importing certificates becomes even easier.

#requires -Version 2.0 -Modules PKI 
# importing to personal store
$Path = 'C:\Path\To\CertFile.cer'
Import-Certificate -FilePath $Path -CertStoreLocation Cert:\CurrentUser\My

Note how Import-Certificate lets you specify the target store location with -CertStoreLocation. It returns the imported certificate.

Twitter This Tip! ReTweet this Tip!