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
Start PowerShell by opening a command prompt and running
powershell(Windows) orpwsh(PowerShell Core).On Windows, this launches the default PowerShell version. For PowerShell Core, use the standalone
pwshexecutable from the Microsoft Store.Type commands normally at the prompt until you reach the point where you want to pause.
For example, run these steps:
- Type
Write-Host "Processing step 1..."and press Enter. - Type
Write-Host "Processing step 2..."and press Enter. - At this point, type
Pausedirectly 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.- Type
If you want to pause in a script file, open a text editor, add the
Pauseline, and save it as a .ps1 file.- Example script structure:
@{ Write-Host "Checking system..."; Pause; Write-Host "Continuing..."; } - Run the script with
.\YourScript.ps1in PowerShell.
PowerShell will pause at the
Pauseline, and you can press Enter or a key to continue.- Example script structure:
Common Mistakes
Forgetting to type
Pauseexactly (case-sensitive): Some users confuse it withpause(lowercase), which returns a 0 exit code instead of pausing. Always typePause.Running scripts in scripts: If your script already contains
Pausecommands, the secondPausein 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-Hostpause instead:Write-Host "Press Enter to continue..."; $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")Using
Read-Hostto pause: WhileRead-Hostcan pause, it prompts for input, which is less useful than a cleanPausemessage.Example of
Read-Host:Write-Host "Press Enter to continue..."; $null = Read-Host
Tips
Use
Write-Hostwith a prompt for interactive scripts: For more control, replacePausewith:Write-Host "Press Enter to continue..."; $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")This avoids the
Press any keymessage 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-Jobfor long tasks: For processes that run for hours, consider running in a job (withStart-Job) and stopping withStop-Jobafter a delay.Save state with
Export-Clixml: If pausing is impractical, log progress withExport-Clixmlbefore pausing and restore withImport-Clixmllater.
Troubleshooting
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.Pause shows but no prompt: If running on Windows PowerShell 5.x and the message is missing, try:
- Run PowerShell as Administrator.
- Update PowerShell using
winget upgrade powershell(Windows 10/11).
For PowerShell Core (7+), the
Pausecommand works by default.The script continues unexpectedly: If the script resumes immediately after typing
Pause, it may be caught by a$Host.UI.RawUI.ReadKeytrap 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.