Powershell: get output from Receive-Job

前端 未结 7 1625
误落风尘
误落风尘 2020-12-09 08:57

I have a collection of jobs that are running. When they complete I use receive-job and it writes the output to the screen. I\'d like to take that output and log it to a file

7条回答
  •  孤街浪徒
    2020-12-09 09:13

    You could pipe your Get-Process to Format-Table, so you can see all of the output.

        Get-Process -Name "explorer" | format-Table -hidetableheaders -AutoSize
    

    And you could use something like this at the end of the script...

        Get-job | Receive-Job 2>&1 >> c:\path\to\your\log\file.log
    

    The "2>&1 >>" with grab all output from Get-Job | Receive-Job

提交回复
热议问题