Test-NetConnection
Use Test-NetConnection to test connectivity to a host, optionally on a specific TCP port, and report the route and DNS resolution.
Documentation: Microsoft Learn — test-netconnection
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Test-NetConnection [[-ComputerName] <String>] -Port <Int32> [-InformationLevel <String>] [<CommonParameters>]
Test-NetConnection [[-ComputerName] <String>] -CommonTCPPort <String> [-InformationLevel <String>] [<CommonParameters>]
Test-NetConnection [[-ComputerName] <String>] [-TraceRoute] [-Hops <Int32>] [<CommonParameters>]- Stage 1Test-NetConnection
-ComputerName -Port -InformationLevel -ComputerName -CommonTCPPort -InformationLevel -ComputerName -TraceRoute -Hops
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Test-NetConnection -ComputerName powershellgenie.com
Show reference output
Illustrative output · values vary by environment
ComputerName : powershellgenie.com RemoteAddress : 203.0.113.10 RemotePort : 443 InterfaceAlias : Ethernet SourceAddress : 192.0.2.10 TcpTestSucceeded : True
Test-NetConnection -ComputerName SRV01
Show reference output
Illustrative output · values vary by environment
True
Test-NetConnection -ComputerName SRV01 (2)
Show reference output
Illustrative output · values vary by environment
ComputerName : SRV01
RemoteAddress : 10.20.30.11
TraceRoute : {10.20.30.1, 10.20.30.11}Parameters
Parameter definitions:
-ComputerName-Port-CommonTCPPort-TraceRoute-Hops-InformationLevel
Separate DNS, ping and TCP checks
Test-NetConnection -ComputerName Host -Port 443 checks a TCP connection to a specific port. TcpTestSucceeded reports that connection check; it does not prove that an HTTPS application, certificate or authentication flow is healthy.
Use the result that answers your question
A host may reject ICMP ping while accepting TCP connections. Interpret ping and TCP results separately. Inspect the resolved address, selected interface and source address when multiple network paths are possible.
Quiet output
-InformationLevel Quiet returns a Boolean for a focused check. Use detailed output while diagnosing and a quiet result when a script needs a simple pass/fail condition.
This is a Windows NetTCPIP command, not a cross-platform socket-testing API. Run it from the network location experiencing the fault; a successful test from another machine may follow a different route.
Updated 1 October 2026. Browser outputs are fictional; check the installed module help for your environment.
Recap
Test-NetConnection Use Test-NetConnection to test connectivity to a host, optionally on a specific TCP port, and report the route and DNS resolution.
Next: Test-Path