Skip to content

Instantly share code, notes, and snippets.

@actaneon
Created January 3, 2010 20:43
Show Gist options
  • Save actaneon/268121 to your computer and use it in GitHub Desktop.
Save actaneon/268121 to your computer and use it in GitHub Desktop.
Sign Powershell Script
#Enable Signed Scripts
#Set-ExecutionPolicy AllSigned
#Create Trusted Root CA
#makecert -n "CN=PowerShell Local Certificate Root" -a sha1 -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer -ss Root -sr localMachine
#Create Personal Cert
#makecert -pe -n "CN=PowerShell User" -ss MY -a sha1 -eku 1.3.6.1.5.5.7.3.3 -iv root.pvk -ic root.cer
#Sign Script with Personal Cert
if ($args.length -ne 1) {
write-host "Usage: <filename>"
exit
}
else {
$filename = $args[0]
Set-AuthenticodeSignature $filename @(Get-ChildItem cert:\CurrentUser\My -codesigning)[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment