Skip to content

Wait-RSJob is not working with parameter set Name or ID.  #139

Closed
@exactmike

Description

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Wait-RSJob goes into an unending loop when any parameter set other than Job. It also throws a divide by zero error if the -State parameter is used.
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?

Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?
I'm testing on Powershell 5.1.14393.953 on Windows 10. Have not tested anywhere else but this does not look to be version specific

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

#Code goes here
# Works
$jobs = @(
foreach ($num in 1..5)
{
    $SleepSeconds = $num * 5
    Start-RSJob -ScriptBlock {Start-Sleep -Seconds $using:sleepseconds}  -Name "Sleep$num"
}
)
Wait-RSJob -Job $jobs -verbose #-showprogress
Get-RSJob | Stop-RSJob
Get-RSJob | Remove-RSJob
# None of these Work
$jobs = @(
foreach ($num in 1..5)
{
    $SleepSeconds = $num * 5
    Start-RSJob -ScriptBlock {Start-Sleep -Seconds $using:sleepseconds}  -Name "Sleep$num"
}
)
Wait-RSJob -Name $jobs.name -verbose
Get-RSJob | Stop-RSJob
Get-RSJob | Remove-RSJob
$jobs = @(
foreach ($num in 1..5)
{
    $SleepSeconds = $num * 5
    Start-RSJob -ScriptBlock {Start-Sleep -Seconds $using:sleepseconds}  -Name "Sleep$num"
}
)
Wait-RSJob -id $jobs.id -verbose
Get-RSJob | Stop-RSJob
Get-RSJob | Remove-RSJob
$jobs = @(
foreach ($num in 1..5)
{
    $SleepSeconds = $num * 5
    Start-RSJob -ScriptBlock {Start-Sleep -Seconds $using:sleepseconds}  -Name "Sleep$num"
}
)
Wait-RSJob -InstanceID $jobs.InstanceID -Verbose
Get-RSJob | Stop-RSJob
Get-RSJob | Remove-RSJob
$jobs = @(
foreach ($num in 1..5)
{
    $SleepSeconds = $num * 5
    Start-RSJob -ScriptBlock {Start-Sleep -Seconds $using:sleepseconds}  -Name "Sleep$num" -Batch 'Sleepy'
}
)
Wait-RSJob -Batch 'Sleepy' -Verbose
Get-RSJob | Stop-RSJob
Get-RSJob | Remove-RSJob

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions