Created
September 18, 2016 23:22
-
-
Save ElanHasson/4c92b7dfc54f3950e0bb6596be66a055 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
ipmo PKI | |
$name = [GUID]::NewGuid() | |
$cerFile = "$env:TEMP\$name.cer" | |
$certs = Get-ChildItem Cert:\LocalMachine\My -DnsName localhost -SSLServerAuthentication | ? {($_.FriendlyName -eq 'IIS Express Development Certificate') -and ($_.SignatureAlgorithm.FriendlyName -ieq 'sha256RSA') -and ($_.EnhancedKeyUsageList.Count -eq 1)} | |
if ($certs.Count -eq 0) | |
{ | |
Write-Error 'Cannot find any SHA256 certificate generated by IIS Express. Please make sure that the latest version of IIS Express is installed.' | |
} | |
else | |
{ | |
foreach ($cert in $certs) | |
{ | |
Export-Certificate -Cert $cert.PSPath -FilePath $cerFile -Type CERT | Out-Null | |
Import-Certificate -FilePath $cerFile -CertStoreLocation Cert:\CurrentUser\Root | Out-Null | |
Remove-Item $cerFile -Force | |
} | |
Write-Host 'Successfully installed the certificate to Trusted Root Certification Authorities of the current user.' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment