Why do these image pipes work in PowerShell 7 but fail in PowerShell 5?

November 14, 2026 3 answers
Asked by mildly__offroute_3

On Windows 11, piping image data between native commands such as magick or ffmpeg works in PowerShell 7 and cmd, but fails in PowerShell 5 with errors about the data. What is different, and is there a workaround that does not require installing PowerShell 7?

Answers

Raff

That pipe carries binary image data, not text. Windows PowerShell 5.1 processes native command output as text and then encodes it again when passing it to the next native command. The resulting bytes can be different, so the receiving program may reject them.

PowerShell 7.4 added byte-preserving piping between native commands. Check the exact PowerShell 7 version on the machine where it works, since versions through 7.3 do not have that behavior.

Reply to this answer
2b!notchfinder_580

For machines where you need to stick with PowerShell 5.1, run the native-to-native pipe through cmd from the script. That keeps PowerShell out of the binary data path.

Be careful with quoting when you build the command, especially for filenames containing spaces or other special characters. Test the command with the kinds of paths your script will actually receive.

Reply to this answer
9g+tramline_526

Another option is to use an intermediate file instead of a pipe. Have the first program write its output to a file, then give that file to the second program. It costs disk space and needs cleanup, but avoids passing the binary stream through PowerShell 5.1.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions