# Sign PowerShell script

  1. Create certificate (for example with a windows ca or easyrsa ca). For easyrsa run ./easyrsa sign-req code-signing <cert name>
  2. Create a .pfx cert
  3. 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
  1. Sign the script
Set-AuthenticodeSignature -Certificate $cert -FilePath <path to script to sign>