I am trying to partially automate our cert request process and I am having trouble getting certreq to run remotely. Code is below. The CSR is not generated, and no error is generated, so I am not sure what the issue might be.
$svr = Read-Host "Enter server name"
$cred = [cred]
$dom = (gwmi Win32_ComputerSystem -ComputerName $svr -Credential $cred).Domain
$infPath = "C:\temp\inf.inf"
Set-Content -Value "[Version]
Signature=`"`$Windows NT$`"
[NewRequest]
Subject=`"CN=$svr.$dom`"
Exportable=FALSE
KeyLength=2048
KeySpec=1
MachineKeySet=TRUE
PrivateKeyArchive=FALSE
ProviderName=`"Microsoft RSA SChannel Cryptographic Provider`"
ProviderType = 12
RequestType=PKCS10
Silent=TRUE
UseExistingKeySet=FALSE
UserProtected=FALSE
KeyUsage = 0xF0" -Path "C:\temp\inf.inf" -Force
cp -Path "C:\temp\inf.inf" -Destination "\\$svr\C$\temp\"
$reqString = "certreq -q -new -p C:\temp\inf.inf C:\temp\request.csr"
Invoke-Command -ComputerName [servername] -ScriptBlock {"certreq -q -new -p C:\temp\inf.inf C:\temp\request.csr"} -Credential $cred
cp -Path "\\$svr\C$\temp\request.csr" -Destination "C:\temp\"