Question:
If I have a hash table like..
1 2 |
$theHash = @{"dog"="mean"; "cat"="nice";"bird"="annoying"} |
I can get the key for a value by doing:
1 2 |
$theHash."dog" |
How do I do the reverse? I want to put in something like, “mean” and get “dog” as the output? So if I only know “mean”, how do I get dog from that?
Answer:
1 2 |
$theHash.keys | Where-Object {$theHash["$_"] -eq 'mean'} |