Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/53265d7a7794093b847f to your computer and use it in GitHub Desktop.
Save anonymous/53265d7a7794093b847f to your computer and use it in GitHub Desktop.
$servers = Get-Content 'C:\scripts\servers.txt'
$certName = Read-Host -Prompt 'Enter Certificate Name'
ForEach($server in $servers) {
Copy-Item d:\SSL_Test\Summer\$certName.pfx -Destination \\$server\c$\SSL -force
}
ForEach($server in $servers) { Invoke-Command $server -ScriptBlock {
Function Import-PfxCertificate {
param([String]$certPath,[String]$certRootStore = “CurrentUser”,[String]$certStore = “My”,$pfxPass = $null)
$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()
}
Import-PfxCertificate \\$server\c$\SSL\$certName.pfx "localmachine" "my"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment