Got this from TechNet Script Center

Use a WaitKey Function in Windows PowerShell

Submitted By: Greg Lyon

Language: Windows PowerShell

Description: Sample script that adds a WaitKey function to a Windows PowerShell script.

Script Code

function WaitKey ( [string] $strPrompt = "Press any key to continue ... ")
{
    Write-Host
    Write-Host $strPrompt -NoNewline
    [Console]::ReadKey($true) > $null
    Write-Host
}

# Example:
Write-Host "This is a test of WaitKey"
WaitKey "Press any key to exit ... "
WaitKey
Write-Host


Trackbacks

No Trackbacks

Comments

No Comments