PowerShell’s pause command isn’t a separate command—it’s embedded in the shell itself through the Write-Host or Pause method you trigger by typing Pause directly at the prompt. This feature lets you stop execution before the script finishes, review output, and manually continue. You don’t need any additional tools or permissions; it’s built into every PowerShell installation. Here’s how it works and when to use it.

What You'll Need

  • A running PowerShell session (Windows PowerShell or PowerShell Core 7+).
  • Access to the command prompt or terminal where PowerShell is installed—no special configuration required.
  • Optional: A script file with commands you want to pause midway (requires text editor like Notepad or VS Code).

Step-by-Step

  1. Start PowerShell by opening a command prompt and running powershell (Windows) or pwsh (PowerShell Core).

    On Windows, this launches the default PowerShell version. For PowerShell Core, use the standalone pwsh executable from the Microsoft Store.

  2. Type commands normally at the prompt until you reach the point where you want to pause.

    For example, run these steps:

    1. Type Write-Host "Processing step 1..." and press Enter.
    2. Type Write-Host "Processing step 2..." and press Enter.
    3. At this point, type Pause directly at the prompt.

    The script will halt and display a message like Press any key to continue . . .. Press a key (any letter or number) to resume.

  3. If you want to pause in a script file, open a text editor, add the Pause line, and save it as a .ps1 file.

    1. Example script structure: @{ Write-Host "Checking system..."; Pause; Write-Host "Continuing..."; }
    2. Run the script with .\YourScript.ps1 in PowerShell.

    PowerShell will pause at the Pause line, and you can press Enter or a key to continue.

Common Mistakes

  • Forgetting to type Pause exactly (case-sensitive): Some users confuse it with pause (lowercase), which returns a 0 exit code instead of pausing. Always type Pause.

  • Running scripts in scripts: If your script already contains Pause commands, the second Pause in a nested script will not work because PowerShell treats them as no-ops in loops or functions.

    Example of the issue: function Test-Pause { Pause } Test-Pause Pause # This won't pause, just returns 0.

    Workaround: Use a Write-Host pause instead: Write-Host "Press Enter to continue..."; $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

  • Using Read-Host to pause: While Read-Host can pause, it prompts for input, which is less useful than a clean Pause message.

    Example of Read-Host: Write-Host "Press Enter to continue..."; $null = Read-Host

Tips

  • Use Write-Host with a prompt for interactive scripts: For more control, replace Pause with: Write-Host "Press Enter to continue..."; $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

    This avoids the Press any key message and lets you type a custom message.

  • Pause before error handling: If your script contains try-catch blocks, pause before the catch section to let users review errors before execution resumes.

  • Use PowerShell’s Stop-Job for long tasks: For processes that run for hours, consider running in a job (with Start-Job) and stopping with Stop-Job after a delay.

  • Save state with Export-Clixml: If pausing is impractical, log progress with Export-Clixml before pausing and restore with Import-Clixml later.

Troubleshooting

  1. Script doesn’t pause: Double-check for typos (case-sensitive). If running in a script file, ensure it’s not inside a function or loop that silently ignores Pause. Try running it directly in PowerShell.

  2. Pause shows but no prompt: If running on Windows PowerShell 5.x and the message is missing, try:

    1. Run PowerShell as Administrator.
    2. Update PowerShell using winget upgrade powershell (Windows 10/11).

    For PowerShell Core (7+), the Pause command works by default.

  3. The script continues unexpectedly: If the script resumes immediately after typing Pause, it may be caught by a $Host.UI.RawUI.ReadKey trap elsewhere. Check for hidden code or functions interfering.

Frequently Asked Questions

Can I pause a script running in a different PowerShell session?

No. Only the running session can pause execution via Pause. To halt a job, use Stop-Job instead.

Why does my script skip the Pause command when using a function?

PowerShell treats Pause as a no-op inside functions or loops. Use Write-Host with $Host.UI.RawUI.ReadKey instead, or break into the function to manually pause.

How do I pause a script in PowerShell Core (7+)?

The same Pause command works, but ensure you’re using the .NET 6+ runtime. If no prompt appears, try adding a blank line at the end of the script to force a prompt.

What’s the difference between Pause and Read-Host?

Pause displays a standardized message and waits for any key, while Read-Host prompts for user input. Use Pause for simple halts; Read-Host for custom prompts.

Can I pause a script running in a remote session?

Not directly. PowerShell remote sessions (like Enter-PSSession) don’t support halting execution. Restart the session or use Stop-Job if applicable.

Why does PowerShell 5.x sometimes lack the Pause prompt?

Legacy versions of Windows PowerShell 5.x may lack the full Pause implementation. Use Write-Host with $null = $Host.UI.RawUI.ReadKey as a workaround.

For advanced scenarios, consider using Stop-Job with a timeout or System.Threading.Thread.Sleep to force pauses—but Pause is the simplest built-in method.