In Powershell, you can redirect standard output and error using the well-known redirection operators > , >> , 2> , 2>> .
First, make sure you install:
$ erroractionpreference.value __ = 1
Then use redirection.
<strong> Examples:
ls C:\ 2> stderror.txt > stdoutput.txt # write output on stdoutput.txt
ls foo 2> stderror.txt > stdoutput.txt # write output on stderror.txt unless foo exists
source share