For the longest time, I’ve used a combination of PING, TRACERT, and TELNET to do basic network connectivity testing and troubleshooting. However, telnet is not installed by default, which can present a problem while doing on the fly testing on machines.
Introduced with Windows 8, Test-NetConnection is a Powershell command that can handle most of the features of the above command line tools. This cmdlet is not supported on Windows 7, but I’m sure that all of you have upgraded by now. Right? 🙂
In it’s most basic functionality, it can ping a host.
It can also check to see if a port is open on the site:
TEST-NETCONNECTION GOOGLE.COM -PORT 443
So, what if the port is closed? You’ll get this, complete with whether or not the host is even pingable
TEST-NETCONNECTION GOOGLE.COM -PORT 445
You may be wondering, what are all those other IP’s that it tried? Fortunately, they have a detailed command that we can run. By adding the informationlevel command, we will get more diagnostic information that can be useful.
TEST-NETCONNECTION GOOGLE.COM -INFORMATIONLEVEL DETAILED
As you can see, it lists all of the different IP’s that resolve to that hostname. It will then check each of those when checking whether or not a port is open. Needless to say, this can be very helpful when trying to sort out erratic issues.
You can also see the next hop that it took to get to the site. That will normally be your default gateway, so it can provide an added level of detail when troubleshooting.
I mentioned that this tool can also do some traceroute commands as well. Let’s take a look at that in action. Just add -TRACEROUTE and you’re in business.
TEST-NETCONNECTION 10.42.196.3 -TRACEROUTE
There you go, you can see the hops taken to get to the destination. You’ll note that this doesn’t show as much information as a traditional traceroute, however it gives enough detail to handle the basics.
While it is a bit more complicated, if you run as an admin, you can use the -diagnoserouting -informationlevel detailed switches, and get far, far more information. That’s a bit beyond the scope of this writing however.
Hopefully this has been helpful to you! I am gradually shifting over to this as my go-to basic networking troubleshooting tool, and it is making quite a difference.