Share via


"Pausing" a PowerShell Script

I can't actually remember who showed this to me in the past.  So, I cannot give credit where it is due.

However, I recently was in a situation where I needed to write a PowerShell script (.ps1) that included some pauses while I demonstrated some results.

You can acomplish this by using the following:

Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Of course, you can substitute the "Press any key to continue ..." with any text you want.

Enjoy!