Sumit Murari
Sumit Murari

Reputation: 1689

AWS powershell :Get value of a Tag in ec2 instance

I can fetch the Tag's key-value pair of a instance using powershell.

I have an object, $instance and $instance.Tags yields the following list:

Key                                     Value                                  
---                                     -----                                  
abc                                     cde
mnp                                     mju

How can I retrieve the value of any specific key?

Upvotes: 2

Views: 10606

Answers (2)

Jeremiah Hinrichs
Jeremiah Hinrichs

Reputation: 9

($instance.tags | ? $_.key -eq "mytag").value

Upvotes: 0

arco444
arco444

Reputation: 22831

You can access by filtering on the key:

$instance.Tags | ? { $_.key -eq "mnp" } | select -expand Value

Upvotes: 8

Related Questions