opened
willemdh
username_0
Hello,

I was trying to do some tests with your rsjobs module and received an error saying I'm trying to divide by zero when I try using wait-rsjob

$Test = 42
$AnotherTest = 7
$String = 'SomeString'
$ProcName = 'powershell_ise'
$ScriptBlock = {
    Param($y,$z)
    [pscustomobject] @{
        Test = $y
        Proc = (Get-Process -Name $Using:ProcName)
        String = $Using:String
        AnotherTest = ($z+$_)
        PipedObject = $_
    }
}
 
1..5|Start-RSJob $ScriptBlock -ArgumentList $test, $anothertest
Wait-RSJob
6..10|Start-RSJob $ScriptBlock -ArgumentList $test, $anothertest
Get-RSJob | Receive-RSJob

$Test = 42
$AnotherTest = 7
$String = 'SomeString'
$ProcName = 'powershell_ise'
$ScriptBlock = {
    Param($y,$z)
    [pscustomobject] @{
        Test = $y
        Proc = (Get-Process -Name $Using:ProcName)
        String = $Using:String
        AnotherTest = ($z+$_)
        PipedObject = $_
    }
}
 
1..5|Start-RSJob $ScriptBlock -ArgumentList $test, $anothertest
Wait-RSJob
6..10|Start-RSJob $ScriptBlock -ArgumentList $test, $anothertest
Get-RSJob | Receive-RSJob

At C:\Program Files\WindowsPowerShell\Modules\PoshRSJob\Scripts\Wait-RSJob.ps1:143 char:21
+ ...             Write-Progress -Activity "RSJobs Tracker" -Status ("Remai ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException

Or am I doing something wrong?
Attempt to divide by zero error when using wait-rsjob
issue
created
proxb
username_1
Weird. I will have to check and see what is going on. It shouldn't be using Write-Progress at all if not using -ShowProgress so it seems like a bug to me.
comment
created
willemdh
username_0
Hey, sorry the output was with a write-progress in the command. The issue I was talking about was the divide by zero.
comment
created
proxb
username_1
I couldn't re-produce this in Windows 7, but appears to be an issue with Windows Server 2012 R2. I'll dig some more to see what the issue is and get it fixed.
comment
created
proxb
username_1
Ok, the bug should be fixed now. Had to change a couple of lines of code to avoid that error from popping up.
comment
created
proxb
username_1
Ok, it took me a while to realize what was going on but you aren't actually piping anything into Wait-RSjob or specifying a Name, ID or InstanceID parameter. This is why there are DivideByZero errors.
comment
closed
proxb
username_1
issue