Directly Importing Certificates (Part 1)

Installing certificate files on a computer can be done using .NET methods with any version of PowerShell. This would import a certificate file to your personal store:

# importing to personal store
$Path = 'C:\Path\To\CertFile.cer'
$Store = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList My, CurrentUser
$Store.Open('ReadWrite')
$Store.Add($Path)
$Store.Close()

You can verify it by opening the certificate manager:

 
PS C:\> certmgr.msc
 

If you’d like to import the certificate to a different store location, simply adjust the arguments you submit when creating the store object.

Twitter This Tip! ReTweet this Tip!