问题
We start a Powershell function via Start-Job
and want to retrieve its output in the caller in real time. Is there a nice way to do so without calling Retrieve-Job
in a loop?
回答1:
Try something like this:
$appJob = Start-Job { foreach($i in 1..10) { Write-Output "Testing $i"; Start-Sleep 10 } }
$appJob.ChildJobs[0].Output
来源:https://stackoverflow.com/questions/48909983/start-job-retrieve-output-in-real-time