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 –
Param
(
[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}   
  
   $pfx.import($certPath,$pfxPass,"Exportable,PersistKeySet")   
  
   $store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)   
   $store.open("MaxAllowed")   


   $store.add($pfx)   
   $store.close()

Hope this helps.
Cheers…
Happy Coding!!

Comments

Popular posts from this blog

The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used

Getting Started with Logic Apps - AS2

How to Debug and Trace request in Azure APIM - Portal, Postman, RequestBin