Have Powershell Wait For Minutes

Shell Programming

Have you ever needed to delay a PowerShell script for a specific amount of time? I know I have! In this article, I’ll show you how to make PowerShell wait for a specified number of minutes before continuing with the script execution.

Using Start-Sleep cmdlet

The easiest way to make PowerShell wait is by using the built-in Start-Sleep cmdlet. This cmdlet allows you to specify the number of seconds to wait before the script continues. But what if you want to wait for minutes instead of seconds? Don’t worry, I’ve got you covered.

To convert minutes to seconds, you simply multiply the number of minutes by 60. For example, if you want to wait for 5 minutes, you would use the following command:

Start-Sleep -Seconds (5 * 60)

Automating the Conversion

To make things even easier, you can create a custom function that handles the conversion from minutes to seconds for you. Here’s an example of how you can achieve this:

function Wait-Minutes {
Start-Sleep -Seconds ($Minutes * 60)

Now, whenever you need to wait for a specific number of minutes, you can simply call the Wait-Minutes function with the desired number of minutes as the parameter.

Practical Example

Let’s say you have a PowerShell script that performs some resource-intensive task and you want to wait for 10 minutes before proceeding to the next step. You can easily incorporate the Wait-Minutes function into your script like this:

# Performing resource-intensive task...
Wait-Minutes -Minutes 10
# Continue with the next step...


So there you have it! By leveraging the Start-Sleep cmdlet and creating a custom function, you can make PowerShell wait for minutes with ease. This technique can be especially useful when dealing with automation or scheduling tasks. Happy scripting!