0

我可以能够使用URL http://169.254.169.254/latest/meta-data/instance-id不能从PowerShell中获取实例ID在EC2窗口MACHIN

在同一台机器上得到AWS EC2 Windows计算机的IE浏览器的实例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 

注:Invoke-WebRequest http://google.com工作,并给予从PowerShell的CMD的响应。

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

回答

0

这需要做什么?从URL下载数据?我从来没有见过这样的想起以前,但我认为你可以使用System.Web.Uri类来做到这一点,就像这样:

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

是否类似的东西的工作?

+0

这不会为我工作。 – Mohan 2014-09-22 09:37:28