[英]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.