Sign PowerShell scripts

Hello,

As you may know, you can sign your scripts to ensure they’ll run on “AllSigned” policy, or to be sure about their integrity.

You can find your code signing certificates with :

 Get-ChildItem cert:CurrentUserMy -CodeSigning

So you can sign scripts file with :

$cert = @(Get-ChildItem cert:CurrentUserMy -CodeSigning)[0]
Set-AuthenticodeSignature file.ps1 $cert

And then, check the signature with :

Get-AuthenticodeSignature .test.ps1

Leave a Reply