Closed howardthu closed 8 years ago
Yea, echo is an alias for Write-Output. Can you provide an example of the code you are trying to use? Are you expecting the write-host stream to be displayed when using receive-rsjob? There is a pull request currently submitted that should fix that issue. I just need to review it and merge it.
echo is the alias of write-output. Write-Host has options such as -NoNewline, -ForegroundColor. I can provide an example.
Start-RSJob -ScriptBlock { Write-Host "test" echo "test2" }
Get-RSJob | Wait-RSJob Get-RSJob | Receive-RSJob
In this example, only "test2" gets outputted.
Also, on an unrelated note, can you give me an example on how to call a function (declared outside the scriptblock) from within the scriptblock? I tried using a variable but it didn't seem to work. Thanks
That is expected behavior as of right now. You can track the stream in the rsjob object but as I mentioned above, there is a pull request that I need to review which should add this capability. For the function outside of the rsjob, use the -FunctionsToLoad parameter and supply the function name. An example can be found here: http://blogs.technet.com/b/heyscriptingguy/archive/2015/11/29/weekend-scripter-a-look-at-the-poshrsjob-module.aspx
Duplicate of #20
It still does not work.
Receive-RSJob -Job (Wait-RSJob -Job (Start-RSJob -ScriptBlock { Write-Host "hello" }))
prints nothing.
Invoke-Parallel, on the other hand, works correctly:
0 | Invoke-Parallel { Write-Host $_ }
outputs 0.
on PS v5.0+ Host stream converted into Information stream
but PoshRSJob
still does not support Information stream. (#129)
PS C:\> Receive-RSJob -Job (Wait-RSJob -Job (Start-RSJob -ScriptBlock { Write-Host "hello" }))
PS C:\> $j = Get-RSJob
PS C:\> $j.InnerJob.Streams
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
Information : {hello}
It doesn't do anything. Write-Host does nothing when enclosed in the ScriptBlock. Echo works, but it's not the same.