powershell - 如何在powershell脚本中填写提示

标签 powershell

我使用这样的命令:

获取-pfxcertificate C:\test.pfx

输入密码: *******

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

我需要的是这样的:

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

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

我非常感谢任何回复

最佳答案

没有 Password 参数,您可以尝试使用 .NET 类:

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

关于powershell - 如何在powershell脚本中填写提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14049002/

相关文章:

visual-studio - 在 Web 部署之后运行部署后脚本

c# - 在windows c#中的进程中调用右键单击菜单

powershell - Powershell中Generic Type的泛型类型

powershell - 如何获取下载链接返回的文件名?

azure - 使用 PowerShell 更改 Azure VM 使用的操作系统磁盘

powershell - Powershell 中用于保留 Url 的 netshell 等效命令是什么?

powershell - 在 Powershell 中替换部分文件名

powershell - 如何在PowerShell中 “grep”并显示周围的行/上下文?

powershell - intellij IDEA是否有任何好的PowerShell插件?

PowerShell Copy-Item 在 Octopus 中给出错误