Author Posts

January 1, 2012 at 12:00 am

by leitsu at 2013-04-01 17:54:33

I need a script to ping an IP address from my computer. If the IP address is not available, exit the script. If its available continue with the script.

by Nobody at 2013-04-01 19:23:31

You need the Test-Connection command.


$IP = "x.x.x.x"
IF (Test-Connection -computername $IP -count 1 -quiet){
Do Stuff
}

You could also do it like this

$IP = "x.x.x.x"
IF (!(Test-Connection -computername $IP -count 1 -quiet)){
EXIT
}

Do Stuff