PowerShell Start-Job output

When I run command Start-Job {dir} in PowerShell I get output

Id              Name            State      HasMoreData     Location             Command
--              ----            -----      -----------     --------             -------
43              Job43           Running    True            localhost             dir

How can I make this job write its output to console?


Solution 1:

That's handled through the receive-job cmdlet.

$job = Start-Job { dir }
Receive-Job $job

You only get data if HasMoreData is true on your get-job output. This will return as an array, with one line of text per array-element.

help about_jobs will give you quite a bit of detail about how to interact with jobs in general.