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.

1 vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    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
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      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