Test-NetConnection

Displays diagnostic information for a connection.

Syntax

Test-NetConnection
    [[-ComputerName] <String>]
    [-TraceRoute]
    [-Hops <Int32>]
    [-InformationLevel <String>]
    [<CommonParameters>]
Test-NetConnection
    [[-ComputerName] <String>]
    [-CommonTCPPort] <String>
    [-InformationLevel <String>]
    [<CommonParameters>]
Test-NetConnection
    [[-ComputerName] <String>]
    -Port <Int32>
    [-InformationLevel <String>]
    [<CommonParameters>]

Description

The Test-NetConnection cmdlet displays diagnostic information for a connection. The output includes the results of a DNS lookup, a listing of IP interfaces, an option to test a TCP connection, IPsec rules, and confirmation of connection establishment.

Examples

Example 1: Test a connection

PS C:\>Test-NetConnection
ComputerName : gateway.contoso.com 

RemoteAddress : 2620:0:30::197 

InterfaceAlias : Ethernet 3 

SourceAddress : 2001:4898:1b:1046:cda8:e200:e2cd:1e8b 

PingSucceeded : True

This command tests a network connection.

Example 2: Test a connection and display detailed results

PS C:\>Test-NetConnection -Port 80 -InformationLevel Detailed
ComputerName : gateway.contoso.com 

RemoteAddress : 2620:0:30::197 

RemotePort : 80 

AllNameResolutionResults : 10.253.21.197 

10.79.197.197 

2620:0:30::197 

MatchingIPsecRules : Ipsec-Win8/Domain-TrafficFromInternet-v6 

NetworkIsolationContext : Internet 

InterfaceAlias : Ethernet 3 

SourceAddress : 2001:4898:1b:1046:cda8:e200:e2cd:1e8b 

NetRoute (NextHop) : fe80::21a:30ff:feaf:5400 

PingSucceeded : True 

PingReplyDetails (RTT) : 1 ms 

TcpTestSucceeded : True

This command tests a network connection and sets the InformationLevel parameter to Detailed.

Example 3: Test a connection to a remote host

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

RemoteAddress : 2600:1409::1703:6929 

AllNameResolutionResults : 10.3.105.104 

10.3.105.113 

10.3.105.114 

10.3.105.41 

10.3.105.43 

2600:1409::1703:6929 

2600:1409::1703:692b 

2600:1409::1703:6972 

InterfaceAlias : Ethernet 3 

SourceAddress : 2001:4898:1b:1046:cda8:e200:e2cd:1e8b 

NetRoute (NextHop) : fe80::21a:30ff:feaf:5400 

PingSucceeded : True 

PingReplyDetails (RTT) : 164 ms

This command tests a network connection to a remote host named www.contoso.com.

Parameters

-CommonTCPPort

Specifies the common service TCP port number. The acceptable values for this parameter are:

  • SMB
  • HTTP
  • RDP
  • PING
Type:String
Accepted values:HTTP, RDP, SMB, WINRM
Position:1
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ComputerName

Specifies the Domain Name System (DNS) name or IP address of the target computer that runs the Dynamic Host Configuration Protocol (DHCP) server service.

Type:String
Aliases:RemoteAddress, cn
Position:0
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Hops

Specifies the number of hops to traverse in a trace route command.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InformationLevel

Specifies the information level. The acceptable values for this parameter are:

  • Detailed
  • Quiet

If you set this parameter to Quiet, the cmdlet returns a Boolean value that indicates if the attempt to ping a host or port succeeded.

Type:String
Accepted values:Quiet, Detailed
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Port

Specifies the TCP port number on the remote computer. The cmdlet uses this port number to test connectivity to the remote machine.

Type:Int32
Aliases:RemotePort
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TraceRoute

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

none

Outputs

NetConnectionResults

Results of the connectivity test to the specified computer name