Script for request a certificate using other user's credentials

Hi, 

I need to request for a certificate using other test user's credential. For this requirement I came up with the following script, 

cd C:\temp-folder
Add-Content C:\temp-folder\req.inf "[NewRequest]`r`nSubject=`"CN=Test01`"`r`nRequestType=pkcs10`r`n`r`n[RequestAttributes]`r`nCertificateTemplate=TestUser" #This line would create the inf file

$username = 'MyDomain\Test01'
$password = 'Pass1234'
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

Invoke-Command -Credential $cred -ComputerName localhost -scriptblock {
certreq -new req.inf certnew.req
certreq -submit -config "ca.mydomain.com\MyEnterpriceCA" certnew.req certnew.cer
certreq -accept certnew.cer
}

But when it comes to executing the certreq command, the script hangs. Is there a possible way to come around this issue and request a certificate under MyDomain\Test01 user account via a script ? 

Thank you...

August 6th, 2013 8:49am

Hi,

In MMC you can add Certificates and in personal certificate Advance option you can use ON BEHALF OF users.

Regards,

Yan Li

Free Windows Admin Tool Kit Click here and download it now
August 8th, 2013 10:30pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics