Skip to content

Instantly share code, notes, and snippets.

@jatubio
Last active August 1, 2018 23:06
Show Gist options
  • Save jatubio/1c6e3ebd6d8a66f4d428 to your computer and use it in GitHub Desktop.
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
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