Powershell实现导入安装证书功能脚本分享
支持所有版本。
通常从文件加载一个证书并且安装它到指定的库。可以使用下面的脚本:
代码如下:
$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()
现在你可以配置这个脚本,指定证书的位置和密码。你还可以指定存储位置(当前用户或本地计算机)并添加证书(例如被信任的根证书)或私有证书。
相关推荐
huha 2020-10-16
lianshaohua 2020-09-23
higheels 2020-08-03
ZoctopusD 2020-08-03
酷云的csdn 2020-08-03
higheels 2020-07-27
liushun 2020-06-28
zhendeshifeng 2020-06-22
Sabrina 2020-06-11
CARBON 2020-06-03
CARBON 2020-06-01
DBATips 2020-05-31
higheels 2020-05-29
applecarelte 2020-04-15
Yyqingmofeige 2020-03-28
yoshubom 2020-03-06
Yyqingmofeige 2020-03-02
SciRui 2020-02-26