Start-Sleep

noun

say it: “START SLEEP” /ˈstɑrt ˈslip/

A PowerShell command that pauses a script for a number of seconds or milliseconds before it goes on.

What does Start-Sleep do?

Start-Sleep pauses a script for the time you give it: -Seconds 2, or -Milliseconds 500. In a loop that waits for something, it stops the loop checking thousands of times a second.

while (-not (Test-Path go.txt)) {
    'Waiting for go...'
    Start-Sleep -Seconds 2
}
'Go for launch'
# Waiting for go...   (every 2 seconds, until go.txt appears)
# Go for launch

In a sentence

  • “Start-Sleep makes the launch script wait two seconds between checks.”
  • “Without Start-Sleep, Sam's waiting loop checked for the file thousands of times a second.”

Level: Apprentice · More PowerShell terms at this level

Updated