Skip to content

Instantly share code, notes, and snippets.

Created September 16, 2017 08:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
$MyCert = new-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\my `
-DnsName `
-friendlyname `
-NotAfter ( [DateTime]::Now.AddYears(5)) `
-KeyAlgorithm RSA `
-KeyLength 2048 `
-KeySpec Signature `
-Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" `
-KeyExportPolicy Exportable `
-KeyUsage DigitalSignature `
-Type CodeSigningCert
$MyPath = 'Cert:\LocalMachine\my\' + $MyCert.Thumbprint
Move-Item -Path $MyPath -Destination Cert:\LocalMachine\Root
$cert= Get-ChildItem cert:\localmachine\root -CodeSigningCert |?{$_.friendlyname -eq ""}
Set-AuthenticodeSignature C:\work\Azure\cert\hello.ps1 `
-Certificate $cert `
Get-AuthenticodeSignature -FilePath C:\work\Azure\cert\hello.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment