Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-Expression: redirecting the error stream to the success stream discards error output #10476

Open
mklement0 opened this issue Sep 2, 2019 · 0 comments

Comments

@mklement0
Copy link
Contributor

commented Sep 2, 2019

Note that the symptom only occurs when redirecting to another stream, either via 2>&1 or *>&1.

By contrast, redirecting to a file works as expected.

Steps to reproduce

Run the following Pester test:

# Create a string with a command that writes to all streams.
$cmd = '1; write-error 2; write-warning 3; write-verbose -vb 4; write-debug -debug 5; write-information -infa continue 6'
# Make sure that all streams can be directed to the success output stream (1).
(Invoke-Expression $cmd *>&1).Count | Should -Be 6

Expected behavior

The test should pass - all 6 streams should show up in the success output stream.

Actual behavior

Expected 6, but got 5.

That is, the error output was quietly discarded, as you 'll see if you run the command inside (...) in isolation

Environment data

PowerShell Core 7.0.0-preview.3
Windows PowerShell v5.1.18362.145 on Microsoft Windows 10 Pro (64-bit; Version 1903, OS Build: 18362.295)

@mklement0 mklement0 changed the title Invoke-Expression: redirecting the error streams to the success streams discards error output Invoke-Expression: redirecting the error stream to the success stream discards error output Sep 2, 2019

@iSazonov iSazonov added the Area-Engine label Sep 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.