Search code examples
powershellstderr

Powershell redirect standard output to standard error


In Powershell, how do I redirect standard output to standard error?

I know I can do the converse with 2>&1 so I tried:

echo "Hello" 1>&2

but I get a silly error The '1>&2' operator is reserved for future use.

I ask because being able to do this would make it easier for me to debug another problem. See $LastExitCode=0 but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError


Solution

  • Alas, it's not possible to redirect standard output to standard error. I think that's an unfortunate omission. Let's hope this is fixed in a future version of Powershell.