Skip to content

Instantly share code, notes, and snippets.

@ChabaOk
Created September 16, 2017 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChabaOk/7fef50bdc0d508b4322a3220314d2bb9 to your computer and use it in GitHub Desktop.
Save ChabaOk/7fef50bdc0d508b4322a3220314d2bb9 to your computer and use it in GitHub Desktop.
$MyCert = new-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\my `
-DnsName api.vm360degee.com `
-friendlyname api.vm360degree.com `
-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 "api.vm360degree.com"}
Set-AuthenticodeSignature C:\work\Azure\cert\hello.ps1 `
-Certificate $cert `
-TimestampServer http://timestamp.comodoca.com/authenticode
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