PowerShell Genie

Test-NetConnection

Use Test-NetConnection to test connectivity to a host, optionally on a specific TCP port, and report the route and DNS resolution.

Command 2 min read PowerShell 7 on Windows

Documentation: Microsoft Learn — test-netconnection

Syntax

1PS> Test-NetConnection [[-ComputerName] <String>] -Port <Int32> [-InformationLevel <String>] [<CommonParameters>]
2PS> Test-NetConnection [[-ComputerName] <String>] -CommonTCPPort <String> [-InformationLevel <String>] [<CommonParameters>]
3PS> Test-NetConnection [[-ComputerName] <String>] [-TraceRoute] [-Hops <Int32>] [<CommonParameters>]
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>]
  1. Stage 1Test-NetConnection-ComputerName -Port -InformationLevel -ComputerName -CommonTCPPort -InformationLevel -ComputerName -TraceRoute -Hops

    Try it

    Windows PowerShell

    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.

    Interactive simulation · fictional data

    Examples

    Test-NetConnection -ComputerName powershellgenie.com

    1PS> Test-NetConnection -ComputerName powershellgenie.com -Port 443
    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

    1PS> Test-NetConnection -ComputerName SRV01 -CommonTCPPort WINRM -InformationLevel Quiet
    Show reference output

    Illustrative output · values vary by environment

    True

    Test-NetConnection -ComputerName SRV01 (2)

    1PS> Test-NetConnection -ComputerName SRV01 -TraceRoute -Hops 10
    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

    Microsoft Learn — test-netconnection

    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.

    Inspect DNS resolution

    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
    Genie guideTest-NetConnection

    Use Test-NetConnection to test connectivity to a host, optionally on a specific TCP port, and report the route and DNS resolution. The console below is pre-loaded — run it, then change a value and run it again.