Test Ports With Test-NetConnection

Check connectivity, DNS resolution and a specific TCP port with one cmdlet.

WindowsnetworkpowershellDiagnosticsLow risk
Run Test-NetConnection example.com -Port 443 to test DNS, ping and TCP reachability.

01Command

Command
$ Test-NetConnection example.com -Port 443

02What it does

The cmdlet returns a structured object with DNS resolution results, ping replies and TCP test results, so a script can branch on connectivity without parsing text. That makes it the natural building block for health checks and preflight validation on Windows.

03Risk

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: TCP tests are blocked in some networks and ICMP may be disabled; interpret failures with the other fields, not in isolation.

04Undo

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

05Sources

  • Test-NetConnection
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Tests network connectivity and TCP port reachability.

Last verified: 2026-10-13 · Category: Network

06Related solutions