PowerShell · TROUBLESHOOTING

PowerShell: Check Open TCP Ports on Windows Servers

Use PowerShell Test-NetConnection to test common infrastructure ports such as DNS, SMB, WinRM, RDP, HTTPS and SQL Server.

Practical Runbook6 StepsIssues → Solutions → Recommendations
!Issue

Use PowerShell Test-NetConnection to test common infrastructure ports such as DNS, SMB, WinRM, RDP, HTTPS and SQL Server.

Solution

01 Choose the target

Recommendations

06 Validate from the correct source Repeat the test from the system that actually needs the connection because network controls can differ by source subnet.

Define the server and port list based on the application dependency you need to validate.

01

Choose the target

02

Test each port

Use Test-NetConnection -ComputerName <server> -Port <port> and capture TcpTestSucceeded.

03

Use DNS-aware testing

Test the hostname and, when appropriate, the IP address separately to distinguish DNS problems from network or firewall problems.

04

Export results

Return one object per port with target, port and status so results can be written to CSV.

05

Interpret failures

A failed TCP test proves the connection could not be established from that source. It does not by itself identify whether the cause is the server, firewall, route or service.

06

Validate from the correct source

Repeat the test from the system that actually needs the connection because network controls can differ by source subnet.

Explore more TechRunbook guides

Continue with practical infrastructure troubleshooting, PowerShell scripts and operational runbooks.

Browse all articles →