Re-Encoding ISE-Scripts

by Oct 26, 2011

When you save scripts with the PowerShell ISE script editor, they are saved with the rather unusual "Big Endian Unicode" encoding. That's bad because this is the only encoding that you cannot digitally sign. In PowerShell V3, this has been fixed. Meanwhile, you can use code like this to re-encode all PowerShell scripts in your personal folders:

Get-ChildItem $home -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue | 
  ForEach-Object { 
    (Get-Content -Path $_.FullName) | 
      Set-Content -Path $_.FullName -Encoding UTF8 
  } 

Twitter This Tip!
ReTweet this Tip!