Powershell无法Ping一个网址

时间:2019-02-04 15:44:08

标签: powershell ping

我在Windows 10 64Bit中以管理员身份运行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),

但是,当我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

有什么想法吗?

2 个答案:

答案 0 :(得分:4)

这确实不是powershell问题。事实上,这根本不是问题。 Ping正在使用ICMP。它基本上是一个回显消息。公司可以阻止并且不允许ICMP。

所以,仅仅因为没有ping并不意味着某些东西不起作用。

答案 1 :(得分:1)

某些Web服务器配置为不响应ping。正如ArcSet在上面回答的那样,Ping失败的事实并不意味着网站已关闭。 幸运的是,有一个快速修复程序:Test-NetConnection,它允许您检查特定的端口。语法如下(在本例中为HTTPS):

Test-NetConnection powershellgallery.com -Port 443

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

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

干杯。