Skip to content

Instantly share code, notes, and snippets.

@maravedi
Created November 12, 2020 16:36
Show Gist options
  • Save maravedi/a254ac24903e3f3b1e08a8906de9b059 to your computer and use it in GitHub Desktop.
Save maravedi/a254ac24903e3f3b1e08a8906de9b059 to your computer and use it in GitHub Desktop.
$Cert = New-SelfSignedCertificate -DnsName "maravedi.github.io" -CertStoreLocation Cert:\CurrentUser\My -Type CodeSigningCert -Subject "Code Signing Certificate"
$TempFilePath = "exported_cert.cer"
Export-Certificate -FilePath $TempFilePath -Cert $Cert
$CertFromFile = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($TempFilePath)
$RootStore = Get-Item cert:\LocalMachine\Root
$RootStore.Open("ReadWrite")
$RootStore.Add($CertFromFile)
$RootStore.Close()
Remove-Item $TempFilePath -Confirm:$False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment