In this guide, we'll cover every method to pause and resume PowerShell scripts.
Published: May 02, 2025
Whether you’re waiting on a database update, managing system resources, or automating a batch process, there are times when a PowerShell script needs to pause execution before continuing. But not all pauses are created equal—sometimes, you need a simple Enter key prompt, while other times, a precise number of seconds delay is necessary.
In this guide, we’ll cover every method to pause and resume PowerShell scripts, including:
The most interactive way to pause a script is by asking the user to press the Enter key. The Read-Host cmdlet provides an easy way to achieve this:
Read-Host -Prompt "Press Enter to continue..."
If you don’t want user input echoed back, use NoEcho:
Read-Host -Prompt "Enter your password" -AsSecureString
The NoEcho parameter prevents input from being displayed on the screen, perfect for passwords and sensitive data.
For a more controlled user pause, use [console]::ReadKey()
instead:
Write-Host "Press any key to continue..."
[console]::ReadKey($true)
This waits for a single key press without requiring Enter.
When you need to pause execution without user interaction, the Start-Sleep cmdlet is the best tool. It pauses execution for a specified period of time, measured in seconds or milliseconds.
Basic Sleep Command
Start-Sleep -Seconds 5
Pauses the script for 5 seconds before continuing.
Using Milliseconds Parameter
Start-Sleep -Milliseconds 500
Pauses for half a second, perfect for fine-tuning automation.
The Start-Sleep command also supports the Timespan object for more flexible delays:
Start-Sleep -Duration (New-TimeSpan -Seconds 10)
Use Start-Sleep -Duration with a Timespan object when you need dynamic delays in your script.
In PowerShell automation, errors are inevitable. Whether a file is missing, a service is unavailable, or a command fails due to permissions, you need structured error handling.
The try/catch block prevents errors from breaking your script and lets you handle issues gracefully.
Example: Handling Missing Files
try {
$content = Get-Content "C:\Data\NonexistentFile.txt"
Write-Host "File read successfully: $content"
} catch {
Write-Host "Could not read file: $($_.Exception.Message)"
}
In production scripts, you might log errors, retry failed operations, or trigger alerts.
The PowerShell Console Host (conhost.exe) is often overlooked but plays a key role in automation, especially for persistent session execution and runspace management.
Why Use Windows Console for Paused Execution?
Manual Pausing & Resume in Console Host
Start-Job
and Wait-Job
). (Image credit: Tim Warner/Petri.com)While Windows Console (Console Host) is preferred for long-running jobs, Windows Terminal is great for interactive scripting.
Windows Terminal Benefits:
[console]::ReadKey()
within Visual Studio Code. (Image credit: Tim Warner/Petri.com)Pausing and resuming PowerShell scripts is an essential skill for automation. Whether you need to delay execution, wait for a database update, manage a CSV import, or monitor system resources, using the right PowerShell pause command ensures smooth workflows.
PowerShell does not have a built-in pause
command like the Windows Command Prompt does. However, you can achieve the same effect using alternative methods such as:
Read-Host -Prompt "Press Enter to continue"
[System.Console]::ReadKey()
These effectively wait for user input, functioning as a “pause” in script execution.
To pause execution for a specific duration (e.g., 10 seconds), you can use the Start-Sleep
cmdlet:
Start-Sleep -Seconds 10
This halts the script for 10 seconds without requiring user interaction. You can also use -Milliseconds
for more precise timing:
Start-Sleep -Milliseconds 500
To prevent a PowerShell window from closing immediately (e.g., when run from a shortcut or double-clicked), insert a pause at the end of the script:
Read-Host -Prompt "Press Enter to exit"
Or:
[System.Console]::ReadKey()
This ensures the window stays open until the user takes action.
PowerShell doesn’t have a native output pausing mechanism (like the more
command in CMD), but you can control output flow by:
$items = 1..100
foreach ($item in $items) {
Write-Output $item
if ($item % 20 -eq 0) {
Read-Host "Press Enter to continue..."
}
}
Out-Host -Paging
:Get-Help | Out-Host -Paging
This mimics paging output like the more
command.
You can add a pause in PowerShell using any of these methods:
Read-Host "Press Enter to continue"
[System.Console]::ReadKey()
Start-Sleep -Seconds 5
Choose based on whether you need a delay or user-triggered continuation.