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?
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.
$job = Start-Job { dir }
Receive-Job $job
$job.hasMoreData is true, but output is empty. -job $job
in your code-fragment, that's needed. The command help receive-job -examples
will give you very useful information. -Job
has position 1. My problem turned out in PowerGUI that for some reason does not work correctly. Anyway, thanks for help.