Powershell script to ping the gateway

Welcome Forums General PowerShell Q&A Powershell script to ping the gateway

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years ago.

  • Author
  • #5747

    Points: 0
    Rank: Member

    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)){

    Do Stuff

The topic ‘Powershell script to ping the gateway’ is closed to new replies.