简体   繁体   English

无法从EC2 Windows Machin中的Powershell获取实例ID

[英]Not able to get instance-id from powershell in EC2 windows machin

I can able to get the instance-id from AWS EC2 windows machine's IE browser using the URL http://169.254.169.254/latest/meta-data/instance-id 我可以使用URL http://169.254.169.254/latest/meta-data/instance-id从AWS EC2 Windows计算机的IE浏览器获取实例ID

In the same machine when I use Powershell command 在同一台机器上使用Powershell命令时

Invoke-WebRequest http://169.254.169.254/latest/meta-data/instance-id

then I am getting below error 然后我变得低于错误

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

Note: Invoke-WebRequest http://google.com is working and giving the response from PowerShell cmd. 注意: Invoke-WebRequest http://google.com正在运行,并从PowerShell cmd提供响应。

Please anyone clarify what is this error. 请任何人澄清这是什么错误。

What exactly does this need to do? 这到底需要做什么? Download data from the URL? 从URL下载数据? I've never seen such a think before, but I would THINK you could use the System.Web.Uri class to do it, like so: 我以前从未见过这样的想法,但是我想您可以使用System.Web.Uri类来做到这一点,就像这样:

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

Does something like that work? 这样的事情有用吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将EC2 Windows计算机的instance-id放入批处理变量中 - How to get an EC2 Windows machine's instance-id into a batch variable SSH 到 EC2 linux 实例来自 Windows - SSH to EC2 linux instance from Windows 使用 Z2F2D399F0EA88448339FE5514B304 为 Windows EC2 实例配置 static IP 地址 - Configuring static IP address for Windows EC2 instance using powershell 在 Terraform 中的远程 Windows EC2 实例上执行 Powershell 脚本 - Executing Powershell script on remote Windows EC2 instance in Terraform 无法使用 Putty 从 Windows ssh 到 EC2 实例 - Cannot ssh into EC2 instance from Windows using Putty Windows AWS EC2实例用户数据PowerShell不会为系统帐户级别加载Powershell模块 - Windows AWS EC2 Instance User Data PowerShell do not load Powershell Modules for System Account level EC2 - 可以在EC2 Linux实例上运行Windows吗? - EC2 - possible to run Windows on an EC2 Linux instance? 初始化EC2实例时永久设置Windows PowerShell系统路径 - Setting Windows PowerShell system path permanently when initialising an EC2 instance AWS EC2实例Windows的SSh权限 - SSh permissions for aws EC2 instance Windows 如何使用 EC2 实例本身的 PowerShell 知道附加到 EC2 的“IAM 角色”的名称? - How can I know the Name of the “IAM role” attached to EC2 using PowerShell from EC2 Instance itself?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM