When a network application (such as a website, mail server, or database) is not responding, you can use PowerShell to test connectivity. Test-NetConnection cmdlet (alias: tnc) is a powerful built-in tool for diagnosing network issues.
What Is Test-NetConnection?
-
Test-NetConnection(or tnc) is a PowerShell cmdlet available in Windows 8.1, Windows Server 2012 R2, and later.
-
It combines the functionality of ping, traceroute, and port testing into one command.
-
It helps determine if a host is reachable and whether a specific service port is open.
Common Uses of tnc
1. Basic Connectivity Test
Check if a host is reachable:
Powershell
tnc example.com
-
Returns ping results, IP address, and basic connectivity status.
2. Test a Specific Port
Check if a service port is open (e.g., HTTPS on port 443):
Powershell
tnc example.com -Port 443
-
Useful for testing web servers, mail servers, or custom applications.
3. Trace Route to a Host
See the path packets take to reach the destination:
Powershell
tnc example.com -TraceRoute
-
Helps identify where along the route packets are being dropped or delayed.
4. Test with Detailed Output
Get extended diagnostic information:
Powershell
tnc example.com -Port 25 -InformationLevel Detailed
-
Useful for troubleshooting mail servers (SMTP on port 25).
When to Use tnc
-
Website not loading → Test port 80 (HTTP) or 443 (HTTPS).
-
Email not sending → Test ports 25, 465, or 587 (SMTP).
-
Database connection issues → Test the database port (e.g., 3306 for MySQL, 1433 for SQL Server).
-
General connectivity issues → Use -TraceRoute to see where the connection fails.