Created
January 31, 2017 21:02
-
-
Save gjyoung1974/19e9125b5dcdb7776370bebe780a1b23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################# | |
# # | |
# A script to submit a batch of CSRs to a CA # | |
# # | |
################################################# | |
## put this script the directory with your certificate signing requetss | |
$files = Get-ChildItem ".\" | |
# be sure to adjust the $cmdArgs to reflect the appropriate certificate template | |
# and $CAName below | |
# before submitting your batch of requests | |
$cmdArgs = "-submit -attrib `"CertificateTemplate:WebServerSSLCertificates`"" | |
$CAName = "acmeca01.corp.svbank.com\ACME Issuing CA" | |
## for each CSR in the directory, submit it to the CA in pending status | |
for ($i=0; $i -lt $files.Count; $i++) { | |
Write-Host $files[$i].FullName | |
try{ | |
[Diagnostics.Process]$myProcess2 = [Diagnostics.Process]::Start('c:\windows\system32\certreq.exe', $cmdArgs + " " + "-config `"$CAName`"" + " " + $files[$i].FullName ) | |
if($myProcess2.ExitCode){ | |
# Throw an exception is command fails for any reason | |
Write-Host "**certutil" + $cmdArgs + " has failed!**" | |
Exit | |
} | |
$myProcess2.WaitForExit() | |
} | |
## if there's an error, print it out: | |
catch{ | |
Write-Host "**Failed to run set certreq -submit .**" | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment