Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
So I try: $job = Start-Job { dir } Receive-Job $job $job.hasMoreData is true, but output is empty. – Dmitry Fedorkov Jun 19 '12 at 14:36
@DmitryFedorkov You seem to be missing -job $job in your code-fragment, that's needed. The command help receive-job -examples will give you very useful information. – sysadmin1138 Jun 19 '12 at 14:42
It does not matter, because argument -Job has position 1. My problem turned out in PowerGUI that for some reason does not work correctly. Anyway, thanks for help. – Dmitry Fedorkov Jun 20 '12 at 8:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.