如何使用PowerShell从远程计算机上的CA请求证书?

时间:2018-08-21 19:51:43

标签: powershell

我正在尝试在远程计算机上调用PowerShell命令。我想向内部CA要求证书。如果我直接在远程PC上运行以下命令,则操作成功:

Get-Certificate -Template 1.3.6.1.4.1.311.21.8.9612972.3074733.7357589.1249582.14248002.117.5480590.5436517 -Credential $cred -Url ldap: -CertStoreLocation Cert:\LocalMachine\My

当我从同一域中的远程计算机运行以下命令时,出现如下所示的WIN32:87错误。我已在Google上广泛搜索了该错误,并且无法找出问题所在(仅供参考。我已通过使用Enable-WSManCredSSP在脚本中缓解了双跳问题)。

 $user = 'ABCCOmpany\<password>' #We are using the local machine's Administrator account
 $password = ConvertTo-SecureString '<password>' -asplaintext -force
 $credential = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $user, $password
 $RequestAndReceiveCertificateSuccessful = Invoke-Command -Session $s -ScriptBlock{param($cred) Get-Certificate -Template 1.3.6.1.4.1.311.21.8.9612972.3074733.7357589.1249582.14248002.117.5480590.5436517 -Credential $cred -Url ldap: -CertStoreLocation Cert:\LocalMachine\My} -ArgumentList $credential

错误:

The parameter is incorrect. 0x80070057 (WIN32: 87 ERROR_INVALID_PARAMETER)
+ CategoryInfo          : NotSpecified: (:) [Get-Certificate], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.CertificateServices.Commands.GetCertificateCommand
+ PSComputerName        : Agent3

0 个答案:

没有答案