Write UTF-8 output files with Out-File -Encoding utf8
Why your redirected PowerShell output opens as garbled text in Linux tools — the forgotten encoding parameter.
01Command
$ Get-ChildItem C:\Reports | Out-File -FilePath 'C:\Temp\list.txt' -Encoding utf802What it does
In Windows PowerShell 5.1, '>' and Out-File default to UTF-16 LE ('unicode'), which other tools often can't read; explicit -Encoding utf8 fixes that. PowerShell 7 changed the default to utf8NoBOM, which is why the same script behaves differently on different machines. Other useful values: ascii for legacy systems, utf8NoBOM for Linux-friendly output, and oem for console codepage.
03Risk
04Undo
$ Remove-Item 'C:\Temp\list.txt'05Sources
- Out-File | Microsoft LearnEvidence: Microsoft documents Out-File -Encoding with values including utf8, utf8NoBOM, ascii, and unicode, and notes the default encoding differs between Windows PowerShell and PowerShell 7.
- Out-File - PowerShellEvidence: SS64 lists the -Encoding parameter values and explains that '>' in PowerShell is an alias for Out-File.
Last verified: 2026-09-17 · Category: Files & Folders
06Related solutions
Diagnose NTFS file system errors and bad sectors on any volume — including the system drive while Windows is running — before committing to a repair.
Robocopy is Windows' built-in robust file copier: use /MIR to keep a destination folder as an exact one-way mirror of a source, resumable and restartable.
Search inside text files and logs with regex, returning file, line number and match.