Import-PfxCertificate powershell函数在Localmachine上正常工作但在其他虚拟机上使用PowerShell远程处理时无效

时间:2017-06-15 21:47:52

标签: powershell

function Import-PfxCertificate
{
param([String]$certPath,[String]$certRootStore = “CurrentUser”,[String]$certStore = “My”,$pfxPass = $null)
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2
if ($pfxPass -eq $null) {$pfxPass = read-host “Enter the pfx password” -assecurestring}
$pfx.import($certPath,$pfxPass)
#$pfx.import($certPath,$pfxPass,“Exportable,PersistKeySet”)
$store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)
$store.open(“MaxAllowed”)
$store.add($pfx)
$store.close()
}

Import-PfxCertificate “H:\Powershell Script for CRM 2016\CRM2016.testbiztalk.com.pfx” “CurrentUser” “My”


function Import-PfxCertificate
{
param([String]$certPath,[String]$certRootStore = “localmachine”,[String]$certStore = “Other People”,$pfxPass = $null)
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2
if ($pfxPass -eq $null) {$pfxPass = read-host “Enter the pfx password” -assecurestring}
$pfx.import($certPath,$pfxPass)
#$pfx.import($certPath,$pfxPass,“Exportable,PersistKeySet”)
$store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)
$store.open(“MaxAllowed”)
$store.add($pfx)
$store.close()
}

Import-PfxCertificate “H:\Powershell Script for CRM 2016\CRM2016.testbiztalk.com.pfx” "Localmachine" “Other People”

所以这两个函数在LocalMachine和服务器上运行良好,但我尝试使用PowerShell远程处理运行函数,我得到如下错误!

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

您必须接受一个提示对话框。此对话框无法以编程方式接受。