当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

作者:精品下载站 日期:2024-12-14 07:18:33 浏览:16 分类:玩电脑

PowerShell:使用 Test-NetConnection 检查打开/关闭的端口


我玩得越多,就越喜欢它:Test-NetConnection。 Test-NetConnection查看连接信息。我们能用它做什么?

如果未指定计算机名称,则默认值为 internetbeacon.msedge.net。

Test-NetConnection

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

让我们指定远程主机的地址。

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

很高兴看到 a-d.site 的响应速度比信标快得多。 ?

测试 HTTP 连接

是否可以通过 HTTP 建立与 a-d.site 的连接?

Test-NetConnection www.a-d.site -CommonTCPPort HTTP

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

是的。那么 HTTPS 又如何呢?

Test-NetConnection www.a-d.site -Port 443

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

测试 RDP 连接

嗯,我的博客正在运行。希望我的博客无法通过远程桌面 (RDP) 访问。很高兴看到事实并非如此。

Test-NetConnection www.a-d.site -CommonTCPPort RDP

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

使用tracert/traceroute运行测试连接

Traceroute 跟踪数据包到目标主机的路由。您可以使用 Test-NetConnection 执行相同的操作。

Test-NetConnection www.a-d.site -TraceRoute

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

以安静模式运行

安静。仅显示主机是否可以访问。

Test-NetConnection www.a-d.site -InformationLevel Quiet

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

以详细模式运行

要充分利用测试连接,请在详细模式下运行它。请注意有关 DNS 名称解析和下一跳地址的附加信息。

Test-NetConnection www.a-d.site -InformationLevel Detailed

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

远程计算机

远程计算机怎么样? client001 可以通过 DNS 与 dc01 建立连接吗?无需登录client001。只需运行远程命令:

Invoke-Command -ComputerName client001 {Test-NetConnection dc01 -Port 53 -InformationLevel Quiet}

[玩转系统] PowerShell:使用 Test-NetConnection 检查打开/关闭的端口

是的,client001 可以通过 DNS 与 dc01 建立连接。

结论

希望这有帮助。 “较小”的版本是测试连接:现代版本的 ping:测试连接。

或者通过读取路由表找出默认网关的 IP 地址:PowerShell:通过读取路由表来测试本地主机和远程主机上默认网关的连接

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯