如何在powershell脚本中填写提示 [英] How to fill the prompt in powershell script

查看:65
本文介绍了如何在powershell脚本中填写提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这样的命令:

<前>获取-pfxcertificate C:\test.pfx输入密码: *******

命令要求我填写提示.但我不能在我的脚本中做到这一点(例如 test.ps1)

我需要的是这样的:

<前>get-pfxcertificate C:\test.pfx -password "123456"

或类似的东西,这样我就可以运行我的脚本而无需每次都填写提示

非常感谢您的回复

解决方案

没有 Password 参数,你可以用 .NET 类试试:

$cert = 新对象 System.Security.Cryptography.X509Certificates.X509Certificate2$cert.Import('C:\test.pfx','123456','DefaultKeySet')

I use a command like this:

get-pfxcertificate C:\test.pfx

Enter password: *******

The command ask me to fill the prompt. But I can't do that in my script (test.ps1 for ex)

What I need is like this:

get-pfxcertificate C:\test.pfx -password "123456"

or something similar so I can run my script without fill in the prompt each time

I'm very thankful for any reply

解决方案

There's no Password parameter, you can try with a .NET class:

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import('C:\test.pfx','123456','DefaultKeySet')

这篇关于如何在powershell脚本中填写提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆