Instantly share code, notes, and snippets.

Embed
What would you like to do?
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