powershell wait

PowerShell Pause: How to Pause PowerShell Script

There are different reasons you may have PowerShell pause. Sometimes you may need to have a pause in PowerShell to suspend activity in your script in order to wait for another operation to complete or perhaps to prompt the user before continuing. For example, maybe you want a PowerShell pause for 30 seconds, or you may need a PowerShell pause for input routine. Let’s explore different ways how to pause PowerShell script.

1. PowerShell pause seconds: Let’s say I want to code my powershell script to do a hard pause for 30 seconds. For this I would use the Start-Sleep command…

PowerShell pause for 30 seconds


2. We can pause powershell script execution using the [System.Threading.Thread] namespace with .NET. Notice in System.Threading.Thread.Sleep, 1000 means 1000 miliseconds, which equals 1 second. So if we wanted to make powershell wait 10 seconds, we would use (10000), and in our case, 30000 would pause powershell for 30 seconds.

powershell thread sleep


3. If we really wanted to, we could create our own powershell wait command, using what we learned.

function PowerShell-Wait($seconds)


Incoming search terms:

Best PowerShell Book