Powershell: Writing errors and ouput to a text file and Console
- by smaclell
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.