How to Ping a Computer with PowerShell

We can check whether a computer is active or down by using Ping class in Powershell. Ping allows an application to determine whether a remote computer is accessible over the network.
 

We need create new instance of System.Net.NetworkInformation.Ping to use Send function of ping class. The below command displays the Ping status and IP Address of the computer.

$ping = New-Object System.Net.NetworkInformation.Ping
$ping.Send("Computer-Name")

We can also set a timeout so that our computer doesn’t wait for long time on a server that won’t respond. Let’s add a timeout of a 10 seconds, we will first need to convert this to milliseconds, so that’s 10,000ms.

$ping = New-Object System.Net.NetworkInformation.Ping
$ping.Send("Computer-Name", 10000)
How to Ping a Computer with PowerShell
 

Ping a Computer by IP Address using PowerShell

Instead of computer name, you can also give ip address of the computer as input to send ping command.

$ping = New-Object System.Net.NetworkInformation.Ping
$ping.Send("222.68.1.74", 10000)

Advertisement

Leave a Comment