Start-Sleep
Use Start-Sleep to pause a script for a set time — waiting for a service to start, spacing out retries, or throttling a loop.
Documentation: Microsoft Learn — start-sleep
Syntax
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Examples
Pause for five seconds
Show reference output
Illustrative output · values vary by environment
(pauses for 5 seconds, then continues)
Pause for half a second in a loop
Show reference output
Illustrative output · values vary by environment
Tick 1 Tick 2 Tick 3
Retry a flaky operation up to five times
Show reference output
Illustrative output · values vary by environment
(retries with 5, 10, 15 second waits)
Parameters
Parameter definitions:
-Seconds— Seconds to pause. Accepts decimals, so 0.5 means half a second.-Milliseconds— Milliseconds to pause. Use this for sub-second waits.
Sleep is a guess — prefer waiting for a real condition
A fixed sleep assumes the thing you wait for finishes in exactly that time. On a slow day it finishes late and your script fails; on a fast day you waste time. Where possible, poll for the real condition instead: loop until (Get-Service Spooler).Status -eq 'Running' with a short sleep between checks and a maximum attempt count.
Back-off retries beat fixed retries. Waiting 5 seconds, then 10, then 15 gives a struggling service room to recover without hammering it. Cap the attempts so a permanently dead service fails fast instead of retrying forever.
In PowerShell 7, -Seconds accepts fractional values. In Windows PowerShell 5.1 it only accepts whole seconds, so use -Milliseconds 500 there for half-second waits.
Show progress while waiting with Write-Progress
Check a service state with Get-Service
Updated 25 October 2026. Browser outputs are fictional; check the installed module help for your environment.
Recap
Start-Sleep Use Start-Sleep to pause a script for a set time — waiting for a service to start, spacing out retries, or throttling a loop.
Next: Rename Item