-encoding
parameter are: -encoding
are ascii
bigendianunicode
bigendianutf32
oem
unicode
utf7
(not recommended anymore and causes warning in PowerShell 7.1)
utf8
utf8BOM
utf8NoBOM
utf32
'abc' | out-file abc.txt -encoding 65001 'abc' | out-file abc.txt -encoding 1251 'abc' | out-file abc.txt -encoding 'windows-1251'
encoding
is dependent on the PowerShell version. In PowerShell 7, it is utf8NoBOM
, in PowerShell 5.1, it is unicode
. $OutputEncoding
. Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding
enumeration.