Skip to content

Instantly share code, notes, and snippets.

@MagicAndi
Last active November 8, 2018 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MagicAndi/a18f4fd7543ef2491b756b2fb0d30956 to your computer and use it in GitHub Desktop.
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)
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