Prerequisites
Steps to reproduce
I ran across this by accident while trying to workaround issue #20747.
If I'm using PowerShell 7.4.0 and I invoke pwsh with -Command and I redirect the output of pwsh to a file, that file ends up containing CLIXML with an encoded version of the output rather than the actual output, as happens in 7.3.10
When doing this with a script and pwsh -File things work as expected.
This appears to be related to the PR: Support byte stream piping between native commands and file redirection by @SeeminglyScience that was added in preview 4.
Expected behavior
PS> pwsh >x.txt -Command { Write-Output "Hello" }
PS> Get-Content x.txt
Hello
Actual behavior
PS> pwsh >x.txt -Command { Write-Output "Hello" }
PS> Get-Content x.txt
#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Output">Hello</S></Objs>
Error details
Environment data
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
7.3.10

7.4.0

Prerequisites
Steps to reproduce
I ran across this by accident while trying to workaround issue #20747.
If I'm using PowerShell 7.4.0 and I invoke
pwshwith-Commandand I redirect the output ofpwshto a file, that file ends up containing CLIXML with an encoded version of the output rather than the actual output, as happens in 7.3.10When doing this with a script and
pwsh -Filethings work as expected.This appears to be related to the PR: Support byte stream piping between native commands and file redirection by @SeeminglyScience that was added in preview 4.
Expected behavior
Actual behavior
Error details
No error invovled.Environment data
Visuals
7.3.10
7.4.0