Powershell: Setting Encoding for Get-Content Pipeline Powershell: Setting Encoding for Get-Content Pipeline powershell powershell

Powershell: Setting Encoding for Get-Content Pipeline


As suggested here:

Get-Content tmp.log | Out-File -Encoding UTF8 new.log


I would do it like this:

get-content tmp.log -encoding Unicode | set-content new.log -encoding UTF8

My understanding is that the -encoding option selects the encdoing that the file should be read or written in.


load content from xml file with encoding.

(Get-Content -Encoding UTF8 $fileName)