Re-Encoding ISE-Scripts in UTF8

by Aug 30, 2011

PowerShell ISE by default saves .PS1 scripts in a highly unusual big endian Unicode encoding. For example, you cannot digitally sign such files.. Here is a one-liner that will read in all PS1 scripts in your current folder and saves them using UTF8 encoding:

dir *.ps1 | ForEach-Object { (Get-Content -Path $_.FullName) | Set-Content -Path $_.FullName -Encoding UTF8 } 

Make sure you change to the folder with your scripts first or add the folder path to your call to dir:

Dir c:\myscripts -Filter *.ps1 | ForEach-Object { (Get-Content -Path $_.FullName) | Set-Content -Path $_.FullName -Encoding UTF8 } 

Twitter This Tip!
ReTweet this Tip!