Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help!

Status
Not open for further replies.

kcire50

MIS
Jul 29, 2013
1
SG
Hi Guys,

I badly need help regarding the script I am creating. (i am really not a scripter).

I have this script below to request a certificate from my CA server. This script will request a certificate up to the Nth user and export the certs as well as the private key to a local folder.

However, upon checking the certificate, the "Subject" is not what I desired to be (ssotest00x) and becomes the current user who ran the script.

I know there should be a way to do this and the ides are coming in but I can't still figure out what to do..

Need help:)


#Read the instructions document before running.
New-Item C:\Certificates-temp-folder -type directory -Force
cd C:\Certificates-temp-folder

for ($i=1;$i -le 2; $i++)
{
Add-Content C:\Certificates-temp-folder\req$i.inf "[NewRequest]`r`nSubject=`"cn=ssotest00$i,O=XXXX-XX,C=US`"`r`nRequestType=pkcs10`r`n`r`n[RequestAttributes]`r`nCertificateTemplate=SSOUserNew`r`n`r`n[Extensions]`r`n2.5.29.17 = `"{text}`"`r`n_continue_=`"EMail=ssotest00$i@test.com`""
certreq -new req$i.inf certnew$i.req
certreq -submit -config "ssoserver\SSO_CA" certnew$i.req certnew$i.cer
certreq -accept certnew$i.cer
certutil -privatekey -p "ssotest00$i" -exportpfx -user ssotest00$i@test.com ssotest00$i.p12
#del C:\Certificates-temp-folder\req$i.inf
#del C:\Certificates-temp-folder\certnew$i.req
#del C:\Certificates-temp-folder\certnew$i.cer

}


Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top