Joey
October 21, 2023, 9:10pm
1
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
What have you tried so far?
If it’s an array with key/value pairs, then Where-Object
will do the trick.
Olaf
October 21, 2023, 9:44pm
3
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
powershell
Joey
October 21, 2023, 11:19pm
4
I found the answer:
$array.where {$_.name -eq ‘Anne’ }.val2
Olaf
October 21, 2023, 11:46pm
5
Did you actually read the helpful comments on StackOverflow?
OP obviously read Michael’s comment but proceeds to proclaim they found the answer.