简体   繁体   中英

How Do You Get the Name For A Specific Value In A Powershell Hash Table?

If I have a hash table like..

$theHash = @{"dog"="mean"; "cat"="nice";"bird"="annoying"}

I can get the key for a value by doing:

$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?

$theHash.keys | Where-Object {$theHash["$_"] -eq 'mean'}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM