How to query an array for value

Hi,

I have a powershell array with the following contents (where name has unique values):

Name|Val1|Val2
Mary  |25    |32 
Joe    |38    |21 
Anne |38   |17

I would like to query the array with a query that would return val2 (17) for the row that has a value of Anne for Name.

Hi, welcome to the forum :wave:

What have you tried so far?

If it’s an array with key/value pairs, then Where-Object will do the trick.

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you potentially wasting their time.

Thanks

I found the answer:

$array.where {$_.name -eq ‘Anne’ }.val2

Did you actually read the helpful comments on StackOverflow? :man_shrugging:t3:

OP obviously read Michael’s comment but proceeds to proclaim they found the answer.

Not until right now.