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