Powershell: get output from Receive-Job

前端 未结 7 1617
误落风尘
误落风尘 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:14

    I know this is old. I don't use jobs very often so I was obviously having the same problem when I stumbled on this thread. Anyway, I arrived at a different solution so I thought I'd throw it out there.

    Also in PowerShell 5.1 I simply referenced the properties on the Bob Object(s) In my case this looked like:

    $Jobs.ChildJobs.Output | Out-File  -Append
    

    It looks like all the streams are recorded in this way. Simple echoes go to the Output. Write-Host commands go to Information Stream.

    Output        : {}
    Error         : {}
    Progress      : {}
    Verbose       : {}
    Debug         : {}
    Warning       : {}
    Information   : {}
    

    At any rate I hope that's helpful to someone.

提交回复
热议问题