Redirect Write-Host statements to a file

前端 未结 12 1783
鱼传尺愫
鱼传尺愫 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:51

    Define a function called Write-Host. Have it write to a file. You may have some trouble if some invocations use a weird set of arguments. Also, this will only work for invocations that are not Snapin qualified.

提交回复
热议问题