Pause in PowerShell script

While putting together a demo for PowerShell the other day, I wanted to setup a script that would run each section of my demo without having to run a new script for each one (Lazy Admin in training!) Here’s a simple little function that replicates the old DOS based Pause command from the PowerShell Team Blog.

function Pause ($Message=”Press any key to continue…”)
{
Write-Host -NoNewLine $Message
$null = $Host.UI.RawUI.ReadKey(”NoEcho,IncludeKeyDown”)
Write-Host “”
}

Advertisements
Explore posts in the same categories: PowerShell, Tech

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: