Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Codesign Powershell script

I work with some Powershell, and sometimes I even have to run Windows systems. Loading a function library was more complicated than it should have been, because I hadn't gotten my powershell script signed with a certificate. So here's how to do it with a valid cert.

$cert = (Get-ChildItem Cert:\localmachine\My -CodeSigningCert)[0]
Set-AuthenticodeSignature -File C:\Path\To\File.ps1 -Cert $cert -IncludeChain "All" -TimestampServer http://sha256timestamp.ws.symantec.com/sha256/timestamp

References

  1. How to Sign Digitally PowerShell Script With Code Signing.

Comments