Advertisement
Raimonds

import_cert_w7

Mar 18th, 2016
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #This might work with w8 or w10, not tested.
  2. #Default params if no input given.
  3. param(
  4.     [String]$certName,
  5.     [String]$certRootStore = "LocalMachine",
  6.     [String]$certStore = "root"
  7. )
  8.  
  9. #Cert repo
  10. $file=("\\namespace\it\deploy\certificates\" + $certName)
  11.  
  12. #Only proceed if cert exists on fileshare
  13. If (Test-Path $file){
  14.  
  15.     $pfx=new-object System.Security.Cryptography.X509Certificates.X509Certificate2
  16.     $pfx.import $file
  17.     $store= new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)
  18.     $store.open("MaxAllowed")
  19.     $store.add($pfx)
  20.     $store.close()
  21.  
  22. }Else{
  23.     exit 1
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement