您现在的位置是:网站首页> 编程资料编程资料
Powershell实现导入安装证书功能脚本分享_PowerShell_
2023-05-26
358人已围观
简介 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()
现在你可以配置这个脚本,指定证书的位置和密码。你还可以指定存储位置(当前用户或本地计算机)并添加证书(例如被信任的根证书)或私有证书。
相关内容
- Windows Powershell 定义函数_PowerShell_
- Windows Powershell Switch 循环_PowerShell_
- Windows Powershell For 循环_PowerShell_
- Powershell小技巧之使用WS-Man来调用PowerShell命令_PowerShell_
- 使用HTTP api简单的远程执行PowerShell脚本_PowerShell_
- Powershell小技巧之开启关闭远程连接_PowerShell_
- PowerShell实现在控制台中插入绿色的打勾符号_PowerShell_
- PowerShell中终止管道的方法_PowerShell_
- Powershell实现监测服务器连通状态_PowerShell_
- PowerShel程序执行完后删除脚本自身的方法_PowerShell_
