Please feel free to provide feedback or file bugs here.

Receive-Job duplicates Write-Host output

Starting in PowerShell 5.1, if a background job uses Write-Host, the Receive-Job cmdlet shows each line of output twice.

# Steps to Reproduce
1. Run this command: `Start-Job { 1..10 | % { Start-Sleep -Milliseconds 10 ; Write-Host $_ } } | Wait-Job | Receive-Job`
2. Note the duplicate numbers. This error does not happen in Powershell 6.0.4.

2 votes
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Aaron Jensen shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Aaron Jensen commented  ·   ·  Flag as inappropriate

    It looks like this is related to the $InformationPreference variable. If it is set to "Continue", when Receive-Job runs, it duplicates the output.

    One workaround is to set the InformationAction parameter on Receive-Job to "SilentlyContinue":

    Start-Job { 1..10 | % { Start-Sleep -Milliseconds 10 ; Write-Host $_ } } | Wait-Job | Receive-Job -InformationAction SilentlyContinue

Feedback and Knowledge Base