Signing your Powershell Profile Scripts

Posted Monday, April 23, 2007 7:38 PM by cromwellryan

Running with Set-ExecutionPolicy as AllSigned or Restricted with a roaming profile?  Here's a cmdlet pair that will sign all the scripts in your profile directory.  Makes life easier on me as I include a number of scripts into my main profile for readability:

function sign-profile()
{
    dir $Profiledir\*.ps1 | foreach-object { sign-script $_.FullName }
}

function sign-script( $scriptsource )
{
    get-item $scriptsource
    Set-AuthenticodeSignature $scriptsource @(Get-ChildItem cert:\CurrentUser\My -codesigning)[0]
}

And if you aren't already using Powershell, stop wasting your time with the Command Prompt and go get it.  Don't forget the Powershell Community Extensions

Filed under:

Leave a Comment

(required) 
(required) 
(optional)
(required)