当前位置: 移动技术网 > IT编程>脚本编程>Shell > Powershell实现导入安装证书功能脚本分享

Powershell实现导入安装证书功能脚本分享

2017年12月08日  | 移动技术网IT编程  | 我要评论

支持所有版本。
通常从文件加载一个证书并且安装它到指定的库。可以使用下面的脚本:

复制代码 代码如下:

$pfxpath = 'c:\temp\test.pfx'
$password = 'test'
[system.security.cryptography.x509certificates.storelocation]$store = 'currentuser'
$storename = 'root'
 
add-type -assemblyname system.security
$certificate = new-object system.security.cryptography.x509certificates.x509certificate2
$certificate.import($pfxpath, $password, 'exportable')
 
$store = new-object system.security.cryptography.x509certificates.x509store($storename, $storelocation)
$store.open('readwrite')
$store.add($certificate)
$store.close()

现在你可以配置这个脚本,指定证书的位置和密码。你还可以指定存储位置(当前用户或本地计算机)并添加证书(例如被信任的根证书)或私有证书。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网