Mastering PowerShell Pause and Resume: How to Control Script Execution Like a Pro

In this guide, we'll cover every method to pause and resume PowerShell scripts.

Published: May 02, 2025

powershell hero 16 9 ratio

SHARE ARTICLE

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 PowerShell pause commands (Read-Host, Start-Sleep, Wait-Process, and more).
  • How to use the Start-Sleep command effectively to pause PowerShell for a specified period of time.
  • Handling user input pauses with Read-Host -Prompt and NoEcho.
  • Using Windows Console (PowerShell Console Host) for session persistence and automation.
  • Running paused scripts efficiently in Windows Terminal.

1. Prompting Users: The PowerShell Pause Command

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..."
  • Great for debugging, step-by-step execution, or interactive scripts.

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.

PowerShell pause - Windows Terminal prompting user interaction using Read-Host, waiting for the user to press ENTER.
PowerShell pause – the simplest option using Read-Host (Image Credit: Tim Warner/Petri.com)

2. Delaying Execution: The Start-Sleep Cmdlet and Duration Parameter

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.

PowerShell script in VS Code demonstrating a timed pause with Start-Sleep and an active Write-Progress countdown in the integrated terminal.

3. Handling Errors and Exceptions with Try/Catch

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)"
}
  • If the file exists, the script reads and displays it.
  • If the file is missing, the catch block intercepts the error and prints a friendly message instead of crashing.

In production scripts, you might log errors, retry failed operations, or trigger alerts.

4. Managing PowerShell Script Execution in Windows Console (PowerShell Console Host)

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?

  • Long-running scripts maintain state, unlike Windows Terminal tabs that reset.
  • Background jobs persist across network logins when run in Console Host.
  • Remote automation workflows often rely on session-based execution (Enter-PSSession).

Manual Pausing & Resume in Console Host

  • CTRL + S → Freezes execution until you press CTRL + Q.
  • CTRL + C → Terminates execution entirely.
  • Use Start-Job and Wait-Job → To pause execution asynchronously.
PowerShell session in VS Code executing a background job, demonstrating Start-Job, Wait-Job, and job result retrieval with timestamps.
Managing persistent PowerShell script execution with background jobs (Start-Job and Wait-Job). (Image credit: Tim Warner/Petri.com)

5. Running Paused Scripts in Windows Terminal

While Windows Console (Console Host) is preferred for long-running jobs, Windows Terminal is great for interactive scripting.

Windows Terminal Benefits:

  • Multiple profiles for different PowerShell versions (pwsh.exe, powershell.exe).
  • Split panes for debugging and watching jobs in parallel.
  • Easier navigation with tab switching.
PowerShell script in VS Code paused interactively using [console]::ReadKey(), prompting user to press any key before continuing.
Creating interactive pauses in PowerShell scripts using [console]::ReadKey() within Visual Studio Code. (Image credit: Tim Warner/Petri.com)

Final thoughts: Master PowerShell pauses

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.

  • Use Start-Sleep for delays.
  • Use Wait-Process for external apps.
  • Use Read-Host -Prompt for interactive pauses.
  • Use jobs for long-running scripts you pause and resume.
  • Prefer Console Host (conhost.exe) for automation with persistent sessions.
  • Use Windows Terminal for modern, interactive scripting.

Frequently Asked Questions

1. Is there a pause command in PowerShell?

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.

2. How do I pause PowerShell for 10 seconds?

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

3. How do you pause PowerShell before closing?

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.

4. How do you pause PowerShell console output?

PowerShell doesn’t have a native output pausing mechanism (like the more command in CMD), but you can control output flow by:

  • Breaking output into pages manually and waiting for user input:
$items = 1..100
foreach ($item in $items) {
    Write-Output $item
    if ($item % 20 -eq 0) {
        Read-Host "Press Enter to continue..."
    }
}
  • Piping output to Out-Host -Paging:
Get-Help | Out-Host -Paging

This mimics paging output like the more command.

5. How to add a pause in PowerShell?

You can add a pause in PowerShell using any of these methods:

  • To wait for user input:
Read-Host "Press Enter to continue"
  • To wait for a key press:
[System.Console]::ReadKey()
  • To pause for a duration:
Start-Sleep -Seconds 5

Choose based on whether you need a delay or user-triggered continuation.

SHARE ARTICLE