I am running a command
hg st
and then checking it\'s $LASTEXITCODE to check for availability of mercurial in the current director
$LASTEXITCODE
A fun thing you can do is to pipe the output to Write-Verbose, then you can still see it if you need it by running your script with the -Verbose switch.
ping -n 2 $APP 2>&1 | Write-Verbose