November 20, 2024

How to use sleep (wait) in PowerShell

In PowerShell, the Start-Sleep cmdlet is used to pause the execution of a script or command for a specified amount of time.

This can be useful in a variety of situations, such as when you want to wait for a certain event to occur or for a certain amount of time to pass before continuing with the script. Keep in mind that the Start-Sleep cmdlet is not a replacement for a proper timing mechanism in your script; it simply causes the script to pause for the specified amount of time.

PowerShell start-sleep syntax

Full Command: Start-Sleep
Alias: Sleep
Parameters: -Milliseconds (-m)  -Seconds (-s)
Example: start-sleep -s 4

PowerShell sleep examples

PowerShell sleep example output

Nick Wijnands

Hello, my name is Nick. I have a passion for Computers and i love to share my knowledge and write about it. If you have any questions, dont mind to ask them. Happy Reading.

View all posts by Nick Wijnands →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.