-
-
Save amendoncabh/4c83abe69646779003e0c1f05ea9b0e9 to your computer and use it in GitHub Desktop.
Show "Press any key to continue ..." and Wait until a key is pressed #powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function WaitForKey | |
{ | |
<# | |
.Synopsis | |
Show "Press any key to continue ...." and Wait until a key is pressed. | |
.Description | |
Can show a text before waiting. | |
.Notes | |
Author : Juan Antonio Tubio <jatubio@gmail.com> | |
GitHub : https://github.com/jatubio | |
Date : 2015/04/11 | |
Version : 1.0 | |
.Parameter text | |
Text to show | |
.Outputs | |
Nothing | |
.Example | |
WaitForKey "Debug messages" | |
#> | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$False)] | |
[String]$text | |
) | |
Process | |
{ | |
if($text) { Write-Host $text } | |
Write-Host "Press any key to continue ..." | |
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment