Unable to Sign PowerShell Scripts

Figured it out. The script file was created using PowerShell ISE and apparently you can't sign scripts created in PowerShell ISE or more accurately you can't sign Unicode Big Endian encoded files which is the default for ISE. There's workaround to change the default encoding as documented in link.


Originally added to question by Chad Miller. Relocated his update to an answer so this question no longer shows up as unanswered.


You can save a file as a specific encoding from within the Powershell ISE with the .Save() method of the ISEFile object:

 $psIse.CurrentFile.Save([System.Text.Encoding]::UTF8)

If you add the following to your ISE profile you can just hit Ctrl-Shift-S to get a different default encoding for your scripts:

$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Save as UTF8",{$psIse.CurrentFile.Save([System.Text.Encoding]::UTF8)},"Ctrl+Shift+S")

Here's some quickie code to create your profile if it doesn't exist and add the menu. Run this code from within the ISE or you'll just add junk to your ConsoleHost profile where it will just error out:

add-content $profile -value '$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Save as UTF8",{$psIse.CurrentFile.Save([System.Text.Encoding]::UTF8)},"Ctrl+Shift+S")'