Last active
January 26, 2020 22:12
-
-
Save markwragg/73addf16504caaf72da1633cdac57e68 to your computer and use it in GitHub Desktop.
Powershell script to demonstrate the use of nested progress bars using the write-progress cmdlet. This script uses write-progress to display a running clock of the current time, split in to hours, minutes, seconds and milliseconds. The script stops at midnight.
This file contains hidden or 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
Do{ | |
Write-Progress -Activity "$((get-date).hour) hours" -PercentComplete (((get-date).hour /23) * 100) -Status "$(24 - (get-date).hour) hours remaining" | |
Do{ | |
Write-Progress -Id 1 -Activity "$((get-date).minute) minutes" -PercentComplete (((get-date).minute / 59) * 100) -Status "$(60 - (get-date).minute) minutes remaining" | |
Do{ | |
Write-Progress -Id 2 -Activity "$((get-date).second) seconds" -PercentComplete (((get-date).second / 59) * 100) -Status "$(60 - (get-date).second) seconds remaining" | |
Do{ | |
$Second = (Get-Date).second | |
Write-Progress -Id 3 -Activity "$((get-date).millisecond) milliseconds" -Status "The time is $(get-date -f "HH:mm:ss")" -PercentComplete (((get-date).millisecond / 1000) * 100) -SecondsRemaining (86400 - (((get-date).hour * 60 * 60) + ((get-date).Minute * 60) + ((get-date).Second))) | |
# start-sleep -Milliseconds 100 | |
} | |
Until ((get-date).second -ne $Second) | |
} | |
Until ((get-date).second -eq 0) | |
} | |
Until ((get-date).minute -eq 0) | |
} | |
Until ((get-date).hour -eq 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment