Udostępnij za pośrednictwem


Test-NetConnection

Test-NetConnection

Displays diagnostic information for a connection.

Syntax

Parameter Set: CommonTCPPort
Test-NetConnection [[-ComputerName] <String> ] [-CommonTCPPort] <String> [-InformationLevel <String> ] [ <CommonParameters>]

Parameter Set: ICMP
Test-NetConnection [[-ComputerName] <String> ] [-Hops <Int32> ] [-InformationLevel <String> ] [-TraceRoute] [ <CommonParameters>]

Parameter Set: RemotePort
Test-NetConnection [[-ComputerName] <String> ] -Port <Int32> [-InformationLevel <String> ] [ <CommonParameters>]

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

Parameters

-CommonTCPPort<String>

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

-- SMB
-- HTTP
-- RDP
-- PING

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

-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 a Boolean value that indicates if the attempt to ping a host or port succeeded.

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

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: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

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.

  • NetConnectionResults

    Results of the connectivity test to the specified computer name

Examples

Example 1: Test a connection

This command tests a network connection.

PS C:\> Test-NetConnection

Example 2: Test a connection and display detailed results

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

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

Example 3: Test a connection to a remote host

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

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