Search code examples
powershellcertreq

invoking certreq via powershell


I am trying to build tool which would renew expired certs and I am strugling with invoking certreq command:

this one is working:

Invoke-Command -ComputerName $Srvname -ScriptBlock {Set-Location -Path 'D:\'; $Out = cmd /c 2>&1 'certreq -q -f -new D:\cert\request_new.inf D:\cert\certreq.csr'}

but that one does not

Invoke-Command -ComputerName $Srvname -ScriptBlock {Set-Location -Path 'D:\'; $Out = cmd /c 2>&1 'certreq -f -attrib "CertificateTemplate:WebServer" -submit D:\cert\certreq.csr D:\cert\request.cer'}

I think its because I need to accept the prompt from cert authority and that prompt does not show.

The script works localy when executing:

certreq -f -attrib "CertificateTemplate:WebServer" -submit D:\cert\certreq.csr D:\cert\request.cer

Do you have any ideas?

I have tried psexec but that didnt work either. :S


Solution

  • From the certreq.exe documentation:

    -q      Use silent mode; suppress all interactive prompts.