Redirect Write-Host statements to a file

前端 未结 12 1791
鱼传尺愫
鱼传尺愫 2020-11-29 08:39

I have a PowerShell script that I am debugging and would like to redirect all Write-Host statements to a file. Is there an easy way to do that?

12条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 08:49

    You should not use Write-Host if you wish to have the messages in a file. It is for writing to the host only.

    Instead you should use a logging module, or Set/Add-Content.

提交回复
热议问题