Countdown Timer in PowerShell

Display a countdown that updates the same line each second.

WindowsTerminalpowershellproductivityLow risk
Run the loop to count down from ten; press Ctrl+C to stop early.

01Command

Command
$ 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

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: Interrupting with Ctrl+C leaves the cursor mid-line; run Clear-Host afterwards to tidy the console.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Start-Sleep
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Pauses execution; used to tick the countdown once per second.
  • Write-Host
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Writes to the console; -NoNewline overwrites the same line.

Last verified: 2026-09-20 · Category: System & Settings

06Related solutions