Per the documentation, the Tag
property is a list of Tag
objects. So in general, there will be multiple keys/values stored there. Are you assuming that in your case there is only 1?
Select-Object
allows you to grab not just raw property values, but calculated values as well. Let's say you just want a comma-delimited list of the Value
s from the Tag
objects in the list. Here's how you would do it:
$instances = Get-EC2Instance `
|%{ $_.RunningInstance } `
| Select-Object InstanceId,PublicDnsName,@{Name='TagValues'; Expression={($_.Tag |%{ $_.Value }) -join ','}}
The elements of $instances
will now have a property TagValues
which is a string consisting of the Value
from all Tags associated with the instance.