Skip to content

Instantly share code, notes, and snippets.

@amendoncabh
Forked from jatubio/WaitForKey.ps1
Created August 1, 2018 23:05
Show Gist options
  • Save amendoncabh/4c83abe69646779003e0c1f05ea9b0e9 to your computer and use it in GitHub Desktop.
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
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