华域联盟 PowerShell Powershell实现导入安装证书功能脚本分享

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()

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

本文由 华域联盟 原创撰写:华域联盟 » Powershell实现导入安装证书功能脚本分享

转载请保留出处和原文链接:https://www.cnhackhy.com/14777.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部