Powershell script to ping the gateway

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 3 months ago.

  • Author
    Posts
  • #5747

    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

You must be logged in to reply to this topic.