I want to pipe the output of a command to a file:
PS C:\Temp> create-png > binary.png
I noticed that Powershell changes the encoding and that I can manually give an encoding:
PS C:\Temp> create-png | Out-File "binary.png" -Encoding OEM
However there is no RAW encoding option, even the OEM option changes newline bytes (0xA
resp 0xD
) to the windows newline byte sequence (0xD 0xA
) thereby ruining any binary format.
How can I prevent Powershell from changing the encoding when piping to a file?
Related questions