powershell 无法 ping 通网址

use*_*479 1 powershell ping

我在 Windows 10 64 位中以管理员身份运行 powershell。当我 ping 时www.powershellgallery.com出现错误:

PS C:\WINDOWS\system32> ping www.powershellgallery.com

Pinging psg-prod-eastus.cloudapp.net [40.87.85.101] with 32 bytes of data:
Request timed out.

Ping statistics for 40.87.85.101:
    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
Run Code Online (Sandbox Code Playgroud)

但当我 ping 其他网址(例如 google.com)时,一切正常。

PS C:\WINDOWS\system32> ping www.google.com

Pinging www.google.com [216.58.213.68] with 32 bytes of data:
Reply from 216.58.213.68: bytes=32 time=15ms TTL=56
Reply from 216.58.213.68: bytes=32 time=14ms TTL=56
Reply from 216.58.213.68: bytes=32 time=13ms TTL=56
Reply from 216.58.213.68: bytes=32 time=13ms TTL=56

Ping statistics for 216.58.213.68:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 13ms, Maximum = 15ms, Average = 13ms
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

小智 6

某些 Web 服务器被配置为不响应 ping。正如 ArcSet 上面回复的那样,ping 失败并不意味着网站已关闭。幸运的是,有一个快速解决方案可以帮助您:Test-NetConnection,它允许您检查特定端口。语法如下(在本例中,对于 HTTPS):

Test-NetConnection powershellgallery.com -Port 443

此外,您还可以添加开关InformationLevel。在这种情况下,响应要短得多(True 或 False),如果您想在脚本中使用它,这会非常方便。

Test-NetConnection powershellgallery.com -Port 443 -InformationLevel Quiet

干杯。