Power Shell Script Test Open TCP Ports

Recently I was troubleshooting ADFS connection issues when I discovered a nice little Cmdlet called "Test-NetConnection". With this Cmdelet you can verify TCP connectivity, in my case from a client to the ADFS server.

The Test-NetConnection cmdlet displays diagnostic information for a connection. It supports ping test, TCP test, route tracing, and route selection diagnostics. Depending on the input parameters, the output can include the DNS lookup results, a list of IP interfaces, IPsec rules, route/source address selection results, and/or confirmation of connection establishment.

Find a full documentation on the Microsoft Docs Page.

 

About the script

For troubleshooting purposes I created a little script: Power Shell Script Test Open TCP Ports.

With this Script you are able to specify server names and port numbers to check in a CSV File. The Script generates an CSV output file as a report. You can use this script for troubleshooting or engineering purposes to verify if TCP ports are opened.

Simply add the hostname and TCP port to the "CheckList.csv" and the script checks the specified servers and ports.

The script will generate an output file for the same path containing the suffix "Report_" with the test results.

CheckList.csv:

Report_CheckList.csv gernerated after script execution:

Executing the script

To execute the script simply add the "-Path" parameter to specifiy the path to the CheckList.csv template.

Important:

Power Shell Script Test Open TCP Ports

Downloads

Reference:

 

 

Nicola

The guy behind this blog. Combining work sports and social life.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

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