首页/系统/Windows 运维速查/Test-NetConnection 连通性测试

Test-NetConnection 连通性测试

PowerShell 综合连通测试:DNS 解析、ICMP、TCP 端口与路由追踪一体,替代多个传统命令。

Windows 运维速查系统更新于 2026-10-12
用途测试主机连通性与端口
语法Test-NetConnection [-ComputerName] <目标> [-Port 端口] [-InformationLevel Detailed]
输出PingSucceeded、TcpTestSucceeded、RemoteAddress、InterfaceAlias

常用示例

常用示例
Test-NetConnection 10.0.0.8
Test-NetConnection intranet.contoso.com -Port 443
Test-NetConnection 10.0.0.8 -InformationLevel Detailed
别名 tnc;结果可判断自动化:if ((tnc web01 -Port 445).TcpTestSucceeded) { ... }。

易错点

  • ICMP 被禁时 PingSucceeded=False 不代表主机不可达,需端口测试佐证
  • 默认对 80 端口做 TCP 测试,测其他端口必须加 -Port

数据来源与参考

  • Microsoft Learn:Test-NetConnection

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌