Powershell: Writing errors and ouput to a text file and Console

Posted by smaclell on Stack Overflow See other posts from Stack Overflow or by smaclell
Published on 2010-06-09T18:06:48Z Indexed on 2010/06/09 18:32 UTC
Read the original article Hit count: 202

I am trying to write the entire output (errors included) of an executing script to the console and a file at the same time. I have tried several different options

.\MyScript.ps1 | tee -filePath C:\results.txt # only the output to the file
.\MyScript.ps1 2> C:\results.txt # only the errors to the file and not the console
.\MyScript.ps1 > C:\results.txt # only the output to the file and not the console 

My hope was that I could use the file to review the output/errors

Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about output

Related posts about redirection