AWS powershell :Get value of a Tag in ec2 instance

Sumit Murari picture Sumit Murari · Apr 2, 2015 · Viewed 8.3k times · Source

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?

Answer

arco444 picture arco444 · Apr 2, 2015

You can access by filtering on the key:

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