手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Powershell实现导入安装证书功能脚本分享
Powershell实现导入安装证书功能脚本分享
摘要:支持所有版本。通常从文件加载一个证书并且安装它到指定的库。可以使用下面的脚本:复制代码代码如下:$pfxpath='C:temptest.p...

支持所有版本。

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

复制代码 代码如下:

$pfxpath = 'C:temptest.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实现导入安装证书功能脚本分享】相关文章:

PowerShell入门教程之函数、脚本、作用域介绍

探索PowerShell(六) 脚本基础简要

Powershell小技巧之非相同域或信任域也能远程

PowerShell脚本开发之尝试登录ftp

PowerShell批量安装msi后辍软件的方法

Powershell小技巧之系统运行时间

PowerShell函数实现类似重载功能实例

Powershell小技巧之创建短网址

PowerShell入门教程之编写和使用脚本模块实例

Windows Powershell导出管道结果

精品推荐
分类导航