This is an old revision of the document!


Sign Powershell Script

New-Self​Signed​Certificate

https://community.spiceworks.com/how_to/153255-windows-10-signing-a-powershell-script-with-a-self-signed-certificate

PS C:\tmp\Azure> New-SelfSignedCertificate -CertStoreLocation cert:\currentuser\my -Subject "CN=Local Code Signing" -KeyAlgorithm RSA -KeyLength 2048 -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -KeyExportPolicy Exportable -KeyUsage DigitalSignature ` -Type CodeSigningCert


   PSParentPath: Microsoft.PowerShell.Security\Certificate::CurrentUser\my

Thumbprint                                Subject
----------                                -------
FBEA9166C4E1429775EB6BDEE47E54E49083811C  CN=Local Code Signing


$cert = @(Get-ChildItem cert:\CurrentUser\My -CodeSigning)[0] 

Set-AuthenticodeSignature .\your-script.ps1 $cert
  • qnd/sign_powershell_script.1615406910.txt.gz
  • Last modified: 2021/03/10 20:08
  • by mgupton