I'd like to do something like this:
if (Ping-Host server1) { blah }
Anyone know of a simple way?
I'd like to do something like this:
if (Ping-Host server1) { blah }
Anyone know of a simple way?
Something like this?
if ($(Ping-Host server1 -count 1 -timeout 10).received -eq 1) { blah }
If you are on PowerShell 2.0 I would recommend using Test-Connection -Quiet. It returns a simple true or false indicating whether or not the host can be reached via ping. BTW one of the benefits of Test-Connection is it's built-in whereas ping-host isn't.