Test a TCP port connection on Windows with Test-NetConnection

A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.

WindowsnetworktroubleshootingpowershellLow risk
Run `Test-NetConnection <host> -Port <port>` and check that TcpTestSucceeded comes back True.

01Command

Command
$ Test-NetConnection db-server.example.com -Port 5432

02What it does

Test-NetConnection performs a real TCP three-way handshake to the host and port, printing diagnostics like PingSucceeded, and TcpTestSucceeded. ICMP ping often succeeds while the actual port is firewalled, so this is the honest test for RDP, SQL, SMB, or SMTP reachability. For a machine-readable answer, add `| Select-Object -ExpandProperty TcpTestSucceeded`. It's slower than ping because it waits for the TCP timeout, so a hanging result usually means 'blocked', not 'broken'.

03Risk

RiskLow risk

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Test-NetConnection - PowerShell
    SS64 · technical · 2026-09-17
    Evidence: SS64 documents Test-NetConnection's -Port parameter for testing TCP connectivity and the TcpTestSucceeded result property.
  • PING - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: SS64 explains ping only tests ICMP echo, which many hosts and firewalls block, unlike a TCP port test.

Last verified: 2026-09-17 · Category: Network

06Related solutions