Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Pausing a PS script awaiting user input

$
0
0
Running PSv2. 

I have a script running that needs to pause some way through whilst the user carries out something on the screen manually. What I need to happen is:

i. Script pauses and says "Please carry out MANUAL TASK. Please press Enter once complete"
ii. The script resumes only when ENTER has been pressed on they keyboard

I've found plenty of examples (example below) to pause the script and resume when ANY key has been pressed, but this won't work for me since the user will be legitamately pressing other keys whilst they carry out this manual task!

Write-Host "Press any key to continue ..."

$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Does anyone know how to restrict this to one key (e.g. ENTER), or require some sort of defined input?

Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>