-
Notifications
You must be signed in to change notification settings - Fork 1
/
7-Write-Progress.ps1
42 lines (39 loc) · 1.15 KB
/
7-Write-Progress.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
if ((Get-Host).Name -ne 'ConsoleHost') {
try {
Write-Warning 'This demo works best from the console' -WarningAction Inquire
} catch {
Write-Warning 'Halting as selected'
return
}
}
# taken from Example 4 in the help for Write-Progress
# updated the number of iterations and the delay time
foreach ( $i in 1..3 ) {
Write-Progress -Id 0 "Step $i"
foreach ( $j in 1..5 ) {
Write-Progress -Id 1 -ParentId 0 "Step $i - Substep $j"
foreach ( $k in 1..10 ) {
Write-Progress -Id 2 -ParentId 1 "Step $i - Substep $j - iteration $k"; Start-Sleep -m 50
# I added the following line
Write-Host ('.' * $i) '|' ('.' * $j) '|' ('.' * $k)
}
}
}
Wait-Debugger
$output = @()
$Level1 = 3
$Level2 = 5
$Level3 = 10
$sleepDuration = 50
foreach ( $i in 1..$Level1 ) {
Write-Progress -Id 0 "Step $i"
foreach ( $j in 1..$Level2 ) {
Write-Progress -Id 1 -ParentId 0 "Step $i - Substep $j"
foreach ( $k in 1..$Level3 ) {
Write-Progress -Id 2 -ParentId 1 "Step $i - Substep $j - iteration $k"
Start-Sleep -Milliseconds $sleepDuration
$output += "$('.' * $i) | $('.' * $j) | $('.' * $k)"
}
}
}
$output