Test-NetConnection
Test-NetConnection
Displays diagnostic information for a connection.
語法
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>]
詳細描述
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.
參數
-CommonTCPPort<String>
Specifies the common service TCP port number. 此參數接受的值包括:
-- SMB
-- HTTP
-- RDP
-- PING
別名 |
無 |
必要? |
true |
位置? |
2 |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
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.
別名 |
RemoteAddress,cn |
必要? |
false |
位置? |
1 |
預設值 |
無 |
接受管線輸入? |
True (ByValue, ByPropertyName) |
接受萬用字元? |
false |
-Hops<Int32>
Specifies the number of hops to traverse in a trace route command.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
false |
-InformationLevel<String>
Specifies the information level. 此參數接受的值包括:
-- 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.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
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.
別名 |
RemotePort |
必要? |
true |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
True (ByPropertyName) |
接受萬用字元? |
false |
-TraceRoute
Indicates that Tracert runs to test connectivity to the remote host.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
false |
<CommonParameters>
此 Cmdlet 支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 與 -OutVariable。如需詳細資訊,請參閱 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。
輸入
輸入類型是您可以使用管線處理方式傳遞給 Cmdlet 的物件類型。
- none
輸出
輸出類型是 Cmdlet 所發出的物件類型。
NetConnectionResults
Results of the connectivity test to the specified computer name
範例
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