Export (0) Print
Expand All

Test-NetConnection

Windows Server Technical Preview and Windows 10

Test-NetConnection

Displays diagnostic information for a connection.

Syntax

Parameter Set: CommonTCPPort
Test-NetConnection [[-ComputerName] <String> ] [-CommonTCPPort] <String> {HTTP | RDP | SMB | WINRM} [-InformationLevel <String> {Quiet | Detailed} ] [ <CommonParameters>]

Parameter Set: ICMP
Test-NetConnection [[-ComputerName] <String> ] [-Hops <Int32> ] [-InformationLevel <String> {Quiet | Detailed} ] [-TraceRoute] [ <CommonParameters>]

Parameter Set: NetRouteDiagnostics
Test-NetConnection -DiagnoseRouting [-ConstrainInterface <UInt32> ] [-ConstrainSourceAddress <String> ] [ <CommonParameters>]

Parameter Set: RemotePort
Test-NetConnection [[-ComputerName] <String> ] -Port <Int32> [-InformationLevel <String> {Quiet | Detailed} ] [ <CommonParameters>]




Detailed Description

The Test-NetConnection cmdlet 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.

Parameters

-CommonTCPPort<String>

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

-- SMB
-- HTTP
-- RDP
-- WINRM


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String>

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


Aliases

RemoteAddress,cn

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-ConstrainInterface<UInt32>

Specifies the interface constraint to use for route diagnostics.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ConstrainSourceAddress<String>

Specifies the source address constraint to use for route diagnostics.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DiagnoseRouting

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


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Hops<Int32>

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InformationLevel<String>

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

-- 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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Port<Int32>

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


Aliases

RemotePort

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-TraceRoute

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

Outputs

The output type is the type of the objects that the cmdlet emits.

  • NetRouteDiagnostics

    This object displays route diagnostics information and is returned if you specify the NetRouteDiagnostics parameter set.


  • NetConnectionResults

    This object displays connection results and is returned if you specify the CommonTCPPort, RemotePort, or ICMP parameter set.


Examples

Example 1: Test ping connectivity

This command tests ping connectivity to a default server.


PS C:\>  Test-NetConnection

Example 2: Test ping connectivity with detailed results

This command tests ping connectivity to a default server and sets the InformationLevel parameter to Detailed.


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

Example 3: Test TCP connectivity and display detailed results

This command tests TCP connectivity to a default server and sets the InformationLevel parameter to Detailed.


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

Example 4: Test a connection to a remote host

This command tests ping connectivity to a remote host named www.contoso.com.


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

Example 5: Perform route diagnostics to connect to a remote host

This command performs route diagnostics to reach a remote host named www.contoso.com.


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

Example 6: Perform route diagnostics to connect to a remote host with routing constraints

This command performs route diagnostics to reach a remote host named www.contoso.com with routing constraints.


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

Community Additions

ADD
Show:
© 2016 Microsoft