Created
December 14, 2018 18:59
-
-
Save alevyinroc/98e4b2f2ab105b885f4d3cd64fae2598 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import-module poshrsjob; | |
$PollingInterval = 5; | |
$CompletedThreads = 0; | |
$Status = Get-RSJob | Group-Object -Property State; | |
$TotalThreads = ($Status|Select-Object -ExpandProperty Count | Measure-Object -Sum).Sum; | |
while ($CompletedThreads -lt $TotalThreads) { | |
$CurrentJobs = Get-RSJob; | |
$CurrentJobs.Where( {$PSItem.State -eq "Completed"}) | Receive-RSJob | Out-Null; | |
$CurrentJobs.Where( {$PSItem.State -eq "Completed"}) | Remove-RSJob | Out-Null; | |
$Status = $CurrentJobs|Group-Object -Property State; | |
$CompletedThreads += $Status | Where-Object {$PSItem.Name -eq "Completed"} | Select-Object -ExpandProperty Count; | |
$PctComplete = ($CompletedThreads / $TotalThreads) * 100; | |
Write-Progress -Activity "Downloading Files" -Status "Completed $CompletedThreads of $TotalThreads ($PctComplete)%" -Id 1 -PercentComplete $PctComplete; | |
start-sleep -seconds $PollingInterval; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment