Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Number of items determines the output

$
0
0

When the tag has only one item, the output displays either 'true' or 'false'

PS E:\> Get-EC2Image ami-574772c | Select-Object @{Name='TagValues'; Expression={($_.Tag |%{$_.Value }) -match 'soe'}}

TagValues
---------
True


When the tag has multiple items, the output displays what I want, which it searches through the list and return the item.
PS E:\> Get-EC2Image ami-574772c | Select-Object @{Name='TagValues'; Expression={($_.Tag |%{$_.Value }) -match 'soe'}}

TagValues
---------
yysoe-rhel6-x86_64

 

This means my command doesnt work when there is only one single item in the list. How to change the command so it always returns the item no matter how many items I have in the list?

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles