Powershell: get output from Receive-Job

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

    A simple solution to the problem. Write-Verbose "blabla" -Verbose


    $s = New-PSSession -ComputerName "Computer"
    $j = Invoke-Command -Session $s  -ScriptBlock { Write-Verbose "Message" -Verbose } -AsJob
    Wait-Job $j
    
    $Child = $j.ChildJobs[0]
    $Child.Verbose | out-file d:/job.log -append
    

提交回复
热议问题