Thursday, 10 September 2009

PoSh V2 - Testing Connectivity

Powershell V2 includes a new cmdlet called Test-Connection, that is basically PING. It can be used to stop processing a command if a required computer is not available. Here is the syntax I used:

$computer = "localhost"
$connection = Test-Connection -ComputerName $computer -Quiet -Count 2

If ($connection) {
Write-Host "$computer is available"
} else {
Write-Host "$computer is not available"

No comments:

Post a Comment

Note: only a member of this blog may post a comment.