D.R.
D.R.

Reputation: 21194

Start-Job - retrieve output in real time

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?

Upvotes: 5

Views: 3162

Answers (1)

sirdank
sirdank

Reputation: 3571

Try something like this:

$appJob = Start-Job { foreach($i in 1..10) { Write-Output "Testing $i"; Start-Sleep 10 } }
$appJob.ChildJobs[0].Output

Upvotes: 2

Related Questions