$pfxpath = 'C:/temp/test.pfx'
$pass
word = '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()
現(xiàn)在你可以配置這個(gè)腳本,指定證書的位置和密碼。你還可以指定存儲(chǔ)位置(當(dāng)前用戶或本地計(jì)算機(jī))并添加證書(例如被信任的根證書)或私有證書。