Do a 'Pause' with PowerShell

This comes strait from the Windows PowerShell Team blog on MSDN. To use 'pause' just like you could back in batch file days, all you have to do is include this function in your script or profile. (Script if you want it to be distributeable)


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

Now, when you put 'pause' into your ps1 script it will pause just like in a batch file! Cool!