Here’s something I put together to handle bulk certificate requests for submission to an Enterprise CA using certreq.exe. Enjoy!
######################################################### # # Name: Request-Certificates.ps1 # Author: Tony Murray # Version: 1.0 # Date: 4/12/2012 # Comment: PowerShell script to submit certificate # requests in bulk using certreq.exe # ######################################################### # Specify the location of the request files $csrdir = "C:\Certs\Requests\" ### $files = Get-ChildItem $csrdir $csrs = $files | ? {$_.extension -eq ".csr"} # Parameters $template = "WebServer" # must always use concatenated name format $CA = "MyCAServer.mydomain.com\MyCAName" foreach ($csr in $csrs) { write-host "Requesting certificate $csr ..." $basename = $csr.basename # Specify the command line parameters for certreq.exe $parameters = "-config $CA -submit -attrib CertificateTemplate:$template " ` + "$csrdir" + "$basename" + ".csr " + "$csrdir" + "$basename" + ".cer " ` + "$csrdir" + "$basename" + ".p7b" # Start certreq.exe and pass in the parameters $request = [System.Diagnostics.Process]::Start( "certreq",$parameters ) $request.WaitForExit() write-host "Finished request $csr" #sleep 10 } # end foreach
Great Script, just somethings to point out, firstly you could use the Start-Process cmdlet if instead of the ::Start static method from the BCL. Secondly when you are
Great Script, just somethings to point out, firstly you could use the Start-Process cmdlet if instead of the ::Start static method from the BCL. Secondly when you are