Writing errors and output to a text file and Console

前端 未结 4 1972
走了就别回头了
走了就别回头了 2021-02-02 08:48

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:



        
4条回答
  •  没有蜡笔的小新
    2021-02-02 09:42

    I couldn't get both errors and results in the same file. A workaround that worked for me:

    .\MyScript.ps1 2> C:\errors.txt | tee -filePath C:\results.txt

    Update: I have worked further and I used Start-Transcript and Stop-Transcript in my mode to capture everything and it worked!

提交回复
热议问题