Test-NetConnection

Displays diagnostic information for a connection.

Syntax
      Test-NetConnection [[-ComputerName] String]
         { [-CommonTCPPort] String | -Port Int32 }
            [-InformationLevel String]
               [CommonParameters]

      Test-NetConnection [[-ComputerName] String]
         [-TraceRoute] [-Hops Int32]
            [-InformationLevel String]
               [CommonParameters]

      Test-NetConnection [[-ComputerName] String]
         [-DiagnoseRouting] [-ConstrainSourceAddress String] [-ConstrainInterface UInt32]
            [-InformationLevel String]
               [CommonParameters]

Key
   -ComputerName
       The Domain Name System (DNS) name or IP address of the target computer.

   -CommonTCPPort
       The common service TCP port number.
       Accepted values: SMB  HTTP  RDP  WINRM

   -ConstrainInterface 
       The interface constraint to use for route diagnostics.

   -ConstrainSourceAddress 
       The source address constraint to use for route diagnostics.

   -DiagnoseRouting
       Indicates that route diagnostics runs to output the route and source address selection information for the remote host.

   -Hops
       The number of hops to traverse in a trace route command.


   -InformationLevel 
       The information level.
         Accepted values: 
         • Detailed
         • Quiet    If you set this parameter to Quiet, the cmdlet returns basic information.
                    For example, for a ping test, this cmdlet returns a Boolean value that indicates whether
                    the attempt to ping a host or port is successful.

   -Port
       The TCP port number on the remote computer.
       The cmdlet uses this port number to test connectivity to the remote computer.

   -TraceRoute
       Indicates that Tracert runs to test connectivity to the remote host.

Standard Aliases for Test-NetConnection: tnc

Test-NetConnection displays diagnostic information for a connection. It supports ping test, TCP test, route tracing, and route selection diagnostics. Depending on the input parameters, the output can include the DNS lookup results, a list of IP interfaces, IPsec rules, route/source address selection results, and/or confirmation of connection establishment.

Test-NetConnection is a .psm1 module and can be found in $PSHome\Modules\NetTCPIP.

Examples

Test ping connectivity to a default server:

PS C:\> Test-NetConnection

Test ping connectivity to a default server and set the -InformationLevel parameter to Detailed:

PS C:\> Test-NetConnection -InformationLevel 'Detailed'

Test TCP connectivity to a default server and set the -InformationLevel parameter to Detailed:

PS C:\> Test-NetConnection -Port 80 -InformationLevel 'Detailed'

Test ping connectivity to a remote host named www.example.com:

PS C:\> Test-NetConnection -ComputerName "www.example.com" -InformationLevel "Detailed"

Perform route diagnostics to reach a remote host named www.example.com:

PS C:\> Test-NetConnection -ComputerName www.example.com -DiagnoseRouting -InformationLevel Detailed ComputerName : www.contoso.com

Perform route diagnostics to reach a remote host named www.example.com:

PS C:\> Test-NetConnection -ComputerName "www.example.com" -ConstrainInterface 5 -DiagnoseRouting -InformationLevel "Detailed" ComputerName : www.example.com

“Networking is not about just connecting people. It’s about connecting people with people, people with ideas, and people with opportunities” ~ Michele Jennae

Related PowerShell Cmdlets:

Test-Connection - Ping one or more computers.
Get-NetTCPConnection - Get TCP connections.
Set-NetTCPSetting - Modify a TCP setting.
psp - PowerShell Ping.
PING - Test a network connection.
PATHPING - Route Tracing tool.


 
Copyright © 1999-2024 SS64.com
Some rights reserved