Created
July 22, 2015 20:05
-
-
Save RaccoonDev/b58af43c53e55e9c6687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
TODO: | |
1. Make the script to run itself with elevated permissions. Otherwise it can't open certificate store. | |
2. Take the certificate from some public place. Let's say blob. | |
#> | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$True)] | |
[ValidateScript({ | |
if(Test-Path -Path $_ -PathType Leaf -Include *.cer) {$True} | |
else { Throw "The $_ is not correct. Make sure that file exists and has CER extension." } | |
})] | |
[String] | |
$CertFilePath | |
) | |
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2; | |
$certificate.Import((Get-Item -Path $CertFilePath).FullName); | |
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store( | |
[System.Security.Cryptography.X509Certificates.StoreName]::Root, | |
[System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine); | |
$store.Open("ReadWrite"); | |
$store.Add($certificate); | |
$store.Close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment