简体   繁体   English

Import-PfxCertificate没有提示?

[英]Import-PfxCertificate without prompt?

I have a script which runs Import-PfxCertificate . 我有一个运行Import-PfxCertificate的脚本。 I want it to be able to run automatically, but I am unable to do this because of this prompt: 我希望它能够自动运行,但是由于以下提示,我无法执行此操作:

在此处输入图片说明

Is there a way to automatically answer "Yes" or to not show the prompt at all? 有没有办法自动回答“是”或根本不显示提示? The prompt won't show if I add the -Confirm flag, but then I can't get that to automatically answer "Y", so is there any possible way to automatically run Import-PfxCertificate ? 如果添加-Confirm标志,则不会显示提示,但是我无法自动提示回答“ Y”,因此有没有可能自动运行Import-PfxCertificate

I tried a couple of simple approaches, none of which have worked: 我尝试了几种简单的方法,但都没有成功:

  1. Setting $ConfirmPreference to None $ConfirmPreference设置为None
  2. Trying echo "Y" | Import-PfxCertificate ... 尝试echo "Y" | Import-PfxCertificate ... echo "Y" | Import-PfxCertificate ...
  3. Trying Import-PfxCertificate ... -Confirm:$false 尝试Import-PfxCertificate ... -Confirm:$false

It seems to be related to how the certificate is generated and imported. 它似乎与证书的生成和导入方式有关。 My script was based off this , which: 我的脚本基于this ,它是:

  • generates the certificate in CurrentUser\\My CurrentUser\\My生成证书
  • imports the pfx certificate into LocalMachine\\My 将pfx证书导入LocalMachine\\My
  • imports the certificate into CurrentUser\\My 将证书导入到CurrentUser\\My

If I modify the script to do everything in LocalMachine\\My then I no longer get the prompt (in the OP I thought I was using LocalMachine\\My but turns out I didn't look closely enough and didn't replace CurrentUser\\My in a couple of places). 如果我修改脚本以在LocalMachine\\My执行所有操作,那么我将不再收到提示(在OP中,我以为我正在使用LocalMachine\\My但事实证明我看起来不够仔细,也没有替换CurrentUser\\My几个地方)。

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

相关问题 导入 PfxCertificate 返回 FileNotFoundException - Import-PfxCertificate returns FileNotFoundException Import-PFXCertificate密码问题 - Import-PFXCertificate password issue Import-PFXCertificate:指定的网络密码不正确 - Import-PFXCertificate: The specified network password is not correct Import-PfxCertificate no-ops,但没有错误或任何内容 - Import-PfxCertificate no-ops, but no error or anything 导入带有“Import-PfxCertificate”的证书会导致证书无效 - Importing a certificate with "Import-PfxCertificate" results in an invalid cert 通过 Import-PFXCertificate 导入 PFX 时没有私钥? - No Private Key when importing PFX via Import-PFXCertificate? Import-PfxCertificate 未将证书保存在指定的系统存储位置 - Import-PfxCertificate not saving certificate in designated System Store Location 在 powershell 中使用 Import-PfxCertificate 命令安装证书 pfx 文件时找不到私钥 - private key not found while certificate pfx file installed with Import-PfxCertificate command in powershell Import-PfxCertificate Powershell功能在Localmachine上运行正常,但在其他虚拟机上使用Powershell远程处理时不起作用 - Import-PfxCertificate powershell function work fine on Localmachine but not working when using powershell remoting on other virtual machine 如何登录没有提示? - How to Login without prompt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM