【问题标题】:Not able to get instance-id from powershell in EC2 windows machin无法从 EC2 Windows 机器中的 powershell 获取实例 ID
【发布时间】:2014-09-29 15:53:16
【问题描述】:

我可以使用 URL http://169.254.169.254/latest/meta-data/instance-id 从 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 给出响应。

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

【问题讨论】:

    标签: windows amazon-ec2 powershell-3.0 invoke-command ec2-api-tools


    【解决方案1】:

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

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

    这样的东西有用吗?

    【讨论】:

      猜你喜欢
      • 2010-10-12
      • 2010-10-30
      • 1970-01-01
      • 2011-07-01
      • 2021-06-05
      • 1970-01-01
      • 2013-05-18
      • 2020-05-03
      • 2016-05-13
      相关资源
      最近更新 更多