0

I set an a variable $ec2-instance = GetEC2Instance and this returns something like...

GroupNames : {} Groups : {} Instances : {somekey} OwnerId : 11111111 RequesterId : ReservationId : r-111111111

What I'm trying to do is list just the name of the EC2 instance. I know, "name" is a tag but not sure how to capture in PowerShell.

1
  • I think you mean Get-EC2Instance (Amazon Elastic Compute CLoud). Have a look here Commented Aug 17, 2018 at 13:49

1 Answer 1

1

Get-EC2Instance returns a list of Instances, you can iterate over that list and grab the value of the Name tag like this:

ForEach($i in (Get-EC2Instance).Instances) {
   ($i.Tags | ? { $_.Key -eq "Name"} | select -expand Value)
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.