Wednesday, July 13, 2011

Windows Powershell to import certificate in store

Powershell to import certificate in store.
Quick go through of adding certificates to Trusted Root Store using powershell.
Code is as follows –
[String]$certPath="your certificate path ",
[String]$certRootStore = “CurrentUser”,
[String]$certStore = "root", - this means we are adding certificate to Trusted Root Certification authorities

$pfxPass = "Your password"
   $pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2   

   if ($pfxPass -eq $null) {$pfxPass = read-host "Enter the pfx password" -assecurestring}   
   $store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)   


Hope this helps.
Happy Coding!!

No comments:

Post a Comment