proxb / PoshRSJob

Provides an alternative to PSjobs with greater performance and less overhead to run commands in the background, freeing up the console and allowing throttling on the jobs.
MIT License
541 stars 87 forks source link

Please add -Any parameter to Wait-RSJob, to end wait on first job finishing #183

Open pvspain opened 6 years ago

pvspain commented 6 years ago

Do you want to request a feature or report a bug? I would like to request a new feature

What is the current behavior? Wait-RSJob currently waits for all $Job/$InputObject to finish before the cmdlet completes execution.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

What is the expected behavior? Please emulate the behaviour of PowerShell v3+ Wait-Job -Any parameter, which causes the cmdlet to complete execution when the first job in $Job/$InputObject finishes.

Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?

Please provide a code example showing the issue, if applicable:

# From: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/wait-job?view=powershell-3.0

$s = New-PSSession (Get-Content Machines.txt)
$c = 'Get-EventLog -LogName System | where {$_.EntryType -eq "error" --and $_.Source -eq "LSASRV"} | Out-File Errors.txt'
Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$Using:c}
Invoke-Command -Session $s -ScriptBlock {Wait-Job -Any}