Wait-RSJob -ShowProgress: -Completed & -Activity (as in Write-Progress)
flolilo opened this issue · comments
Do you want to request a feature or report a bug?
Feature.
What is the current behavior?
$foobar | Start-RSJob -Name "XYZ" -ScriptBlock {$_ = $_ + 1} | | Wait-RSJob -ShowProgress
will show a progress-bar similarly to
Write-Progress -Activity "RSJobs Tracker" -Status "Remaining Jobs: $($_.Length - $current_RSJob_index)" -Percentcomplete (($_.Length * 100) / $current_RSJob_index)
. The progress-bar will stay on the console after completion.
What is the expected behavior?
Wait-RSJob -ShowProgress
should, in my opinion, remove the progress-bar after finishing: just like theWrite-Progress
'-Completed
-switch (Which must be called additionally after completion).Wait-RSJob -ShowProgress
should, in my opinion, output the name of the RSJob(s) it is waiting for (or provide an option for it).
Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?
Win10 (1703) x64, PowerShell v5.1
Please provide a code example showing the issue, if applicable:
[int]$ThreadCount = 4
[array]$Files_In = Get-ChildItem -Path .\ -File | ForEach-Object {
[PSCustomObject]@{
FullName = $_.FullName
Hash = $null
}
}
while($true){
foreach($i in $Files_In.FullName){
Write-Output $i
}
$Files_In | Start-RSJob -Name "GetHash" -Throttle $ThreadCount -ScriptBlock {
$_.Hash = Get-FileHash -LiteralPath $_.FullName -Algorithm SHA1 | Select-Object -ExpandProperty Hash
} | Wait-RSJob -ShowProgress | Receive-RSJob
foreach($i in $Files_In.Hash){
Write-Output $i
}
Start-Sleep -Seconds 1
}
In my case Progress do not stay on console after completion but I'm agree, -Completed
should be added after waiting cycle
But about names ... if Jobs count require progress bar, the progress bar can not accommodate all the names :)
especially if your example runned in C:\windows\system32
For me, the behavior is quite inconsitent - with the above script, most of the time, the progress-bar will vanish, but especially in larger scripts, they tend to stick somewhere in the upper lines of the console.
Here is a quick example - the script that spawned it is long completed, as is the RSJob.
Concerning the names: I can understand that and I admit that this is no big issue at all. However, it would be nice if one could state what the script is waiting for. With all the progress-bar-debris it's quite easy to get confused which Wait-RSJob-"iteration" is waiting at the moment, which makes troubleshooting...well, not impossible but just a tad more difficult. ;-)
But again, I suppose there are more pressing concerns than an unnamed progress-bar. ;-)
Manually updated my PoshRSJob?
installation to e454b56
- looking good now! Thanks!