Instantly share code, notes, and snippets.

Embed
What would you like to do?
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