简体   繁体   中英

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!

在此处输入图片说明

在此处输入图片说明

There is a prompt dialog which you have to accept. This dialog can´t be programmatically accept.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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