-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write-Host not working in ScriptBlock #50
Comments
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 { Get-RSJob | Wait-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 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.
The text was updated successfully, but these errors were encountered: