0

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

In the same machine when I use Powershell command

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.

Please anyone clarify what is this error.

Mohan
  • 143
  • 10

1 Answers1

0

What exactly does this need to do? Download data from the 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:

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

Does something like that work?

PSGuy
  • 653
  • 6
  • 17