Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

How to Ping a Computer using PowerShell

Pinging a computer is really simple, and of course since this is PowerShell we don’t want to use something as primitive as ping.exe, we want to use .NET and take advantage of all the method calls and filters.

1
2
$ping = New-Object System.Net.NetworkInformation.Ping
$ping.Send("www.brangle.com")

We can also set a timeout so that our computer doesn’t hang to long on a server that won’t respond. Let’s add a timeout of a 5 seconds, we will first need to convert this to milliseconds, so that’s 5,000ms. Of course 5 seconds may not be a resonable timeout, you need to figure out what’s appropriate for you and what you’re willing to tolerate.

1
2
$ping = New-Object System.Net.NetworkInformation.Ping
$ping.Send("www.brangle.com", 5000)

Technical details: System.Net.NetworkInformation.Ping requires that you have .NET 2.0 or greater.

1 comment to How to Ping a Computer using PowerShell

  • Ping is a computer network tool used to test whether a particular host is reachable across an IP network.It is also used to self test the network interface card of the computer or as a latency test.I commonly do this when checking my internet connection status.

Leave a Reply