运行环境:powershell
语法:Test-NetConnection [[-ComputerName] ] [-CommonTCPPort] {HTTP | RDP | SMB | WINRM}
常用用法
1.测试服务端端口是否开放
Test-NetConnection www.baidu.com -port 80
返回信息:
ComputerName : www.baidu.com
RemoteAddress : 61.135.169.125
RemotePort : 80
InterfaceAlias : WLAN
SourceAddress : 192.168.1.114
TcpTestSucceeded : True
2. 追踪路由
Test-NetConnection www.baidu.com -TraceRoute
返回信息:
ComputerName : www.baidu.com
RemoteAddress : 61.135.169.125
InterfaceAlias : WLAN
SourceAddress : 192.168.1.114
PingSucceeded : True
PingReplyDetails (RTT) : 61 ms
TraceRoute : 192.168.1.1
192.168.0.1
192.168.1.1
61.163.124.1
61.163.185.21
61.168.26.185
219.158.11.101
0.0.0.0
61.51.114.142
123.125.248.110
0.0.0.0
0.0.0.0
61.135.169.125
3. 查看测试详细信息
如需要查看测试相信信息,增加参数 -InformationLevel "Detailed"
Test-NetConnection www.baidu.com -port 80 -InformationLevel "Detailed"
返回信息如下:
ComputerName : www.baidu.com
RemoteAddress : 61.135.169.125
RemotePort : 80
NameResolutionResults : 61.135.169.125
61.135.169.121
MatchingIPsecRules :
NetworkIsolationContext : Internet
InterfaceAlias : WLAN
SourceAddress : 192.168.1.114
NetRoute (NextHop) : 192.168.1.1
TcpTestSucceeded : True