[英]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: 我尝试了几种简单的方法,但都没有成功:
$ConfirmPreference
to None
$ConfirmPreference
设置为None
echo "Y" | Import-PfxCertificate ...
echo "Y" | Import-PfxCertificate ...
echo "Y" | Import-PfxCertificate ...
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 ,它是:
CurrentUser\\My
CurrentUser\\My
生成证书 LocalMachine\\My
LocalMachine\\My
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.