Pausing PowerShell Script Execution
Here's a quick scriptlet that displays a message and also waits for a key to be pressed before the PowerShell script continues.
June 18, 2013
There are various reasons to pause a script. For one, you may need to verify that a section of your script has processed correctly before allowing it to continue. In other cases, you may want to halt the script's execution so you can perform some manual tasks or run a second script to compare results. And, another example might simply be that you want to give the end-user some instructions or allow them to take part in the flow of what is happening on their PC.
Here's a quick scriptlet to add to your own scripts that displays a message and also waits for a key to be pressed before the PowerShell script continues.
Write-Host "Press any key to continue …"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
About the Author
You May Also Like