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:
Have you tried:
.\MyScript.ps1 2>&1 | tee -filePath c:\results.txt
2>&1 is what you're looking for
2>&1
Note: This answer works great in PowerShell 1.0 and 2.0, but will capture ONLY standard output and errors in PowerShell 3.0 and later.