Quantcast
Channel: Security forum
Viewing all articles
Browse latest Browse all 12072

Script for request a certificate using other user's credentials

$
0
0

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...


Viewing all articles
Browse latest Browse all 12072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>