Sign PowerShell scripts


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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.