Tuesday, December 21, 2010

Listing public and private IP addresses of Amazon instances using Powershell

I'm a bit of a Powershell newbie so it took me a few minutes to get this figured out so I thought I'd write it down. Here is how you would list the ID, public IP address and private IP address for each Amazon instance. The script basically gets a list of instances, filters out the instance information and shows just the 3 columns.
.\ec2-describe-instances | %{ if ($_.Split()[0] -match "INSTANCE") { Write-Host $_.Split()[2,16,17] } }

No comments:

Post a Comment