Redirect Write-Host statements to a file

前端 未结 12 1790
鱼传尺愫
鱼传尺愫 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 09:08

    If you have just a few Write-Host statements, you can use the "6>>" redirector operator to a file:

    Write-Host "Your message." 6>> file_path_or_file_name

    This is the "Example 5: Suppress output from Write-Host" provided by Microsoft, modified accordingly to about_Operators.

提交回复
热议问题