简体   繁体   English

Import-PfxCertificate Powershell功能在Localmachine上运行正常,但在其他虚拟机上使用Powershell远程处理时不起作用

[英]Import-PfxCertificate powershell function work fine on Localmachine but not working when using powershell remoting on other virtual machine

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”

So Both functions working fine on LocalMachine as well as on server but I try to run function using PowerShell remoting and I got error as below! 因此,这两个函数在LocalMachine和服务器上均能正常工作,但是我尝试使用PowerShell远程处理来运行函数,但出现以下错误!

在此处输入图片说明

在此处输入图片说明

There is a prompt dialog which you have to accept. 有一个提示对话框,您必须接受。 This dialog can´t be programmatically accept. 该对话框无法通过编程方式接受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM