I would like to get my PowerShell script to pause/wait/sleep by issuing a specific wait time when using the Windows operating system. Resolution:

The PowerShell Sleep command via the Start-Sleep cmdlet allows you to pause a script or module in the PowerShell session until the chosen period has elapsed. When you choose to sleep a PowerShell command, you are always electing to pause it; and there are several ways you can pause your PowerShell commands. We will demonstrate each of those in the tutorial below.

The following tutorial demonstrates how to run the PowerShell sleep command via the Start-Sleep cmdlet as well as put PowerShell scripts and modules to sleep using alternative methods when using a version of the Windows operating system.

Method One: How to Use PowerShell Sleep Command via Start-Sleep cmdlet

The Start-Sleep cmdlet is the main PowerShell sleep command used by administrators most often with the PowerShell sleep loop. Use the Start-Sleep command for console utilities that are native to PowerShell. Here is how to use it:

1. Open the Windows Terminal. See this tutorial for all the different ways in which you can open the Windows Terminal: How to Open Windows Terminal in Windows 11 [Tutorial].

2. Type the following command into the command line and press the Enter key to execute it:

Start-Sleep -Second 300

Note: The above example would be used if you wanted to get PowerShell to sleep for 5 minutes. Change the “-Second 300” part of the command to the time you want to pause the script. You can extend it to sleep for as many minutes or hours as you like.

You can now close the command line and continue using your computer.

Method Two: How to Use PowerShell Sleep Command via Pause Command

The pause command can be used for console utilities that are not native to PowerShell. When the pause command is executed, it will pause the scrips and show the “Press any key to continue . . .” text in the command line until you come back and choose to unpause the session. Here is how to use it:

1. Open the Windows Terminal. See this tutorial for all the different ways in which you can open the Windows Terminal: How to Open Windows Terminal in Windows 11 [Tutorial].

2. Type the following command into the command line and press the Enter key to execute it:

cmd /c 'pause'

You can now close the command line and continue using your computer.

Method Three: How to Use PowerShell Sleep Command via Timeout Command

The timeout command also pauses execution of scripts simialry to the Start-Sleep command where you can choose to allocate a period for the script to timeout for. Here is how to do that:

1. Open Windows PowerShell. See this tutorial for how to open Windows PowerShell in Windows 10 and 11: How to Open Windows PowerShell in Windows 10 [Tutorial].

timeout /t 30

Note: The above example would be used if you wanted to get PowerShell to sleep for 30 seconds. Change the “/t 30” part of the command to the time you want to pause the script. You can extend it to sleep for as many minutes or hours as you like.

2. You can now close the command line and continue using your computer.

While still using the timeout command, you can also pause but force ignoring of key roesees until the chosen time is ellapsed:

1. Open Windows PowerShell. See this tutorial for how to open Windows PowerShell in Windows 10 and 11: How to Open Windows PowerShell in Windows 10 [Tutorial].

timeout /t 30 /nobreak

Note: The above example would be used if you wanted to get PowerShell to sleep for 30 seconds. Change the “/t 30” part of the command to the time you want to pause the script. You can extend it to sleep for as many minutes or hours as you like.

2. You can now close the command line and continue using your computer.

In conclusion, that is how to use the PowerShell sleep command.