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.
01Command
$ Test-NetConnection db-server.example.com -Port 543202What 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Test-NetConnection - PowerShellEvidence: SS64 documents Test-NetConnection's -Port parameter for testing TCP connectivity and the TcpTestSucceeded result property.
- PING - Windows CMDEvidence: 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
Purge cached DNS lookups so Windows re-resolves hostnames from scratch — the fix for 'the new server is live but my browser still hits the old one'.
Display the IP-to-MAC address cache Windows built by talking to neighbors — a quick way to spot which devices are on your subnet.
The PowerShell-native replacement for netstat: filter connections by state, port, or process and pipe results instead of parsing text.