PowerShell Genie

Receive-Job

Use Receive-Job to collect the output of a job and, by default, remove it from the job's buffer.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — PowerShell module reference

Syntax

1PS> Receive-Job [-Job] <Job[]> [-Keep] [-NoRecurse] [-Force] [-Wait] [-AutoRemoveJob] [-WriteEvents] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Receive-Job [-Job] <Job[]> [-Keep] [-NoRecurse] [-Force] [-Wait] [-AutoRemoveJob] [-WriteEvents] [<CommonParameters>]
  1. Stage 1Receive-Job-Job -Keep -NoRecurse -Force -Wait -AutoRemoveJob -WriteEvents

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Start-Job -Name svc

    1PS> Start-Job -Name svc -ScriptBlock { Get-Service | Select-Object -First 2 Name, Status } | Wait-Job | Receive-Job -Keep
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name     Status
    ----     ------
    BITS     Running
    WinRM    Stopped

    Get-Job -Name svc

    1PS> Get-Job -Name svc | Receive-Job -Wait -AutoRemoveJob
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Id  Name  State      HasMoreData  Location
    --  ----  ---------  -----------  ---------
    1   Job1  Completed  True         localhost
    3   Job3  Running    True         localhost

    Parameters

    Parameter definitions:

    • -Job
    • -Keep
    • -NoRecurse
    • -Force
    • -Wait
    • -AutoRemoveJob
    • -WriteEvents

    PowerShell module reference on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Receive-Job when you need to collect the output of a job and, by default, remove it from the job's buffer. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Output disappearing after an earlier receive can be expected because received results are removed by default. Use -Keep when repeated inspection is intentional and track which results were already handled. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-Job. Get-Job returns job metadata such as State; Receive-Job retrieves a job's output. Inspecting a Completed state is not the same as collecting its results. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Receive-Job reference on Microsoft Learn

    Recap

    Receive-Job Use Receive-Job to collect the output of a job and, by default, remove it from the job's buffer.

    Next: Remove-Job
    Genie guideReceive-Job

    Use Receive-Job to collect the output of a job and, by default, remove it from the job's buffer. The console below is pre-loaded — run it, then change a value and run it again.