Countdown Timer in PowerShell
Display a countdown that updates the same line each second.
01Command
$ 10..0 | ForEach-Object { Write-Host "`r$_ seconds remaining " -NoNewline; Start-Sleep -Seconds 1 }02What it does
The range 10..0 is piped to ForEach-Object, which writes the remaining seconds with a carriage return so the same line is overwritten, then sleeps one second. Change the range or use a while loop for longer timers.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Start-SleepEvidence: Pauses execution; used to tick the countdown once per second.
- Write-HostEvidence: Writes to the console; -NoNewline overwrites the same line.
Last verified: 2026-09-20 · Category: System & Settings
06Related solutions
Use the System File Checker to verify every protected Windows system file against known-good copies and automatically replace the damaged ones.
Use Windows Package Manager to install, search, and upgrade thousands of applications from the community repository in one command.
Understand PowerShell's execution policy scopes and set the one that lets you run your own local scripts without gutting the security model.