脚本专栏 
首页 > 脚本专栏 > 浏览文章

Powershell读取PFX证书并输入密码的脚本分享

(编辑:jimmy 日期: 2024/5/20 浏览:3 次 )

支持所有PS版本

当你使用Get-PfxCertificate读取PFX证书去签名你的脚本,但是它总是会已交互式方式提示用户去输入密码。

下面介绍怎么通过脚本去提交密码:

复制代码 代码如下:
$PathToPfxFile = 'C:\temp\test.pfx'
$PFXPassword = 'test'
 
Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($PathToPfxFile, $PFXPassword, 'Exportable')
 
$cert 

上一篇:Powershell小技巧之开启关闭远程连接
下一篇:Powershell小技巧之非相同域或信任域也能远程
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网