Testing Network Connectivity via PowerShell (Part 1)

Ask any IT user how they test basic network connectivity and the majority of answers will probably mention ping. Ping sends a ICMP (Internet Control Message Protocol) packet to a target and then waits for a reply. If ping shows a reply then there is basic network connectivity, if it doesn’t get a reply then there is no network connectivity (or a firewall blocking ICMP packets).

Ping can be used on Windows, Linux and Apple devices, and lots of other network devices even my Virgin SuperHub 2 has a built in ping utility on the hubs settings page.

Fire up your command prompt (cmd) or terminal and type:

ping HOSTNAME (e.g. http://www.wordpress.com) OR IP ADDRESS (192.0.78.13)

and watch as ping receives responses and reports back (in milliseconds) how long the response took. CTRL C,  will end the ping test and report back how many packets were transmitted, how many were received, the percentage (%) of packet loss and the min/max/avg time for the responses.

When it comes to PowerShell the ping command works just as well as it does in cmd.exe, but did you know there is also the Test-Connection command?

Fire up PowerShell and type:

Test-Connection HOSTNAME (e.g. http://www.wordpress.com) OR IP ADDRESS (192.0.78.13)

PowerShell being PowerShell means the fun doesn’t stop there. PowerShell lets you ping multiple computers at the same time.

Test-Connection -ComputerName “WordPress.com” “google.com”

But what about changing packet size and amount of packets sent? In a Windows command prompt adding a few switches like -l (PACKET SIZE e.g 512) and -t increases the packet size and sends more packets than normal. In PowerShell it’s the same, but -Count controls the number of packets to send, -Buffersize controls the packet size and -TTL controls the time-to-live count.

Test-Connection HOSTNAME -Count 10 -TTL 128 -Buffersize 512

The above would send 10 ICMP packets of 512 bytes with a time-to-live of 10 hops.