PowerTip: Use PowerShell to Wait for a Key Press

Doctor Scripto

Summary: Learn about the Windows PowerShell version of “Pause.”

Hey, Scripting Guy! Question How can I use Windows PowerShell to wait for a key in scripts like I used to use “Pause” in the command console?

Hey, Scripting Guy! Answer Use the $Host variable in the console:

$HOST.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) | OUT-NULL
$HOST.UI.RawUI.Flushinputbuffer()

0 comments

Discussion is closed.

Feedback usabilla icon