Port Testing with PowerShell

It’s been a common practice of mine over the past three decades (yes) to use the Telnet client as a quick and easy way of determining whether a TCP port is open between two computers.  As of Windows Server 2012, Telnet Client is not installed by default, which means you often have to install it to do some basic network connectivity testing.  This is not always possible in some environments, but in some places you might be able to use a lightweight, but powerful, alternative.

Assuming you can execute PowerShell commands – not always a given – you can avoid having to install (and uninstall) Telnet client by using this very helpful PowerShell command.  It’s called:

Test-NetConnection

It’s supported on Windows Server 2012 R2 and 2016, Windows 8.1 and 10.

The general syntax is:  Test-NetConnection -Port 80 -InformationLevel Detailed

Which, by the way, uses a Microsoft edge server as the destination (so it tests outbound on port 80 in this case). 

image

The more useful command would be:

Test-NetConnection –ComputerName (HOST or IP) -InformationLevel Detailed
Which produces the following useful output:
image

What happens if a port is blocked?

image 

image

 

Enjoy.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.