#
Sign PowerShell script
- Create certificate (for example with a windows ca or easyrsa ca). For easyrsa run
./easyrsa sign-req code-signing <cert name>
- Create a .pfx cert
- Load the pfx file in PowerShell:
$cert = (Get-ChildItem Cert:/CurrentUser/My/<hash> -CodeSigningCert) #Loads the cert from the cert storage of the computer
$cert = Get-PfxCertificate <path to .pfx file> #Loads the cert from file
- Sign the script
Set-AuthenticodeSignature -Certificate $cert -FilePath <path to script to sign>