Last active
November 8, 2018 11:07
-
-
Save MagicAndi/a18f4fd7543ef2491b756b2fb0d30956 to your computer and use it in GitHub Desktop.
A basic sleep timer with a textual progress indicator (Note, not a progress bar)
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
function Start-SleepTimer | |
{ | |
param | |
( | |
[Alias('s')] | |
[int] $seconds | |
) | |
for($index = $seconds; $index -gt 0; $index--) | |
{ | |
Write-Host "`rCountdown - $index seconds remaining" -NoNewline -ForegroundColor Yellow | |
Start-Sleep -Seconds 1 | |
} | |
# Note use of blank spaces to overwrite previous lines content | |
Write-Host "`rCompleted $seconds second countdown. " -ForegroundColor Yellow | |
} | |
Start-SleepTimer -seconds 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment