Last active
August 1, 2018 23:06
-
-
Save jatubio/1c6e3ebd6d8a66f4d428 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 <[email protected]> | |
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