-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelper-progress.ps1
More file actions
21 lines (19 loc) · 821 Bytes
/
helper-progress.ps1
File metadata and controls
21 lines (19 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$sw = [Diagnostics.Stopwatch]::StartNew()
$swTotal = [Diagnostics.Stopwatch]::StartNew()
$global:progressIdx = 0;
function IncrementProgress {
param($Name);
++$global:progressIdx;
Write-Verbose ("Loading profile $Name " + " (" + $swTotal.Elapsed.ToString() + ", " + $sw.Elapsed.ToString() + ")");
$sw.Restart();
if ($global:progressIdx -eq $global:maxProgress) {
Write-Progress -Activity "Loading Profile" -Complete;
} else {
$percentComplete = (($global:progressIdx) / ($global:maxProgress) * 100);
if ($percentComplete -gt 100) {
Write-Verbose ("You need to update maxProgress to reflect the actual count of IncrementProgress calls in this file.");
$percentComplete = 100;
}
Write-Progress -Activity "Loading Profile" -Status $Name -PercentComplete $percentComplete;
}
}