Skip to content

Instantly share code, notes, and snippets.

@VertigoRay
Created February 4, 2015 00:11
Show Gist options
  • Save VertigoRay/c72c157e25de39384c84 to your computer and use it in GitHub Desktop.
Save VertigoRay/c72c157e25de39384c84 to your computer and use it in GitHub Desktop.
Mimics the command prompt Pause command.
<#
.SYNOPSIS
Mimics the command prompt Pause command.
.DESCRIPTION
Powershell doesn't have a Pause command that Prompts the user with "Press any key to continue..." and waits for a response.
This brings that command to PowerShell and allows you to customize the message.
.PARAMETER Message
The paused Message can be customzied by passing a string.
.INPUTS
.OUTPUTS
.EXAMPLE
Pause
.EXAMPLE
Pause "Waiting for you ..."
.NOTES
.LINK
go.vertigion.com/PowerShell-Pause
#>
function Pause
{
param(
[Parameter(
HelpMessage = "The paused Message can be customzied."
)]
[string] $Message="Press any key to continue..."
)
Write-Host -NoNewLine $Message
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment