How do I write to standard error in PowerShell?
I'm having trouble figuring out how to both echo to the standard error stream and redirect the error stream of an executable. I have come from a Bourne shell and Korn shell background, of which I would use; # Write to stderr echo "Error Message!" >&2 # Redirect stderr to file /do/error 2>/tmp/err.msg Use Write-Error to write to stderr. To redirect stderr to file use: Write-Error "oops" 2> /temp/err.msg or exe_that_writes_to_stderr.exe bogus_arg 2> /temp/err.msg Note that PowerShell writes errors as error records. If you want to avoid the verbose output of the error records, you could write out