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.
Report_CheckList.csv generated after script execution:
Executing the script
To execute the script simply add the "-Path" parameter to specifiy the path to the CheckList.csv template.
PS C:\techblog> &"Check-Ports.ps1" -Path "CheckList.csv"
- This script requires Power Shell version 5
- Don't miss the ExecutionPolicy configuration... dummies.com Run Power Shell Scripts
Power Shell Script Test Open TCP Ports
Download the CSV template
- CSV Template CheckList.csv