无法从EC2 windows machin中的powershell获取实例id

无法从EC2 windows machin中的powershell获取实例id,windows,amazon-ec2,powershell-3.0,invoke-command,ec2-api-tools,Windows,Amazon Ec2,Powershell 3.0,Invoke Command,Ec2 Api Tools,我可以使用URL从AWS EC2 windows机器的IE浏览器获取实例idhttp://169.254.169.254/latest/meta-data/instance-id 在同一台机器上使用Powershell命令时 Invoke-WebRequest http://169.254.169.254/latest/meta-data/instance-id 然后,我得到下面的错误 Invoke-WebRequest : Network Error (tcp_error) A commun

我可以使用URL
从AWS EC2 windows机器的IE浏览器获取实例idhttp://169.254.169.254/latest/meta-data/instance-id

在同一台机器上使用Powershell命令时

Invoke-WebRequest http://169.254.169.254/latest/meta-data/instance-id
然后,我得到下面的错误

Invoke-WebRequest : Network Error (tcp_error) A communication error occurred: "Operation timed out" The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time. For assistance, contact your network support team. At line:1 char:1
+ Invoke-WebRequest http://169.254.169.254/latest/meta-data/instance-id
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
注意:
调用WebRequesthttp://google.com
正在工作,并从PowerShell cmd发出响应


请任何人澄清这是什么错误。

这到底需要做什么?从URL下载数据?我以前从未见过这样的想法,但我认为您可以使用System.Web.Uri类来实现,如下所示:

$var = New-Object System.Web.Uri
$var.Download("http://169.254.169.154/latest/meta-data/instance-id")
这样行吗