如何在 Powershell 哈希 Table 中获取特定值的名称?
How Do You Get the Name For A Specific Value In A Powershell Hash Table?
如果我有一个散列 table 比如..
$theHash = @{"dog"="mean"; "cat"="nice";"bird"="annoying"}
我可以通过以下方式获取值的键:
$theHash."dog"
如何反向操作?我想输入类似 "mean" 的内容并得到 "dog" 作为输出?所以,如果我只知道 "mean",我如何从中得到 dog?
$theHash.keys | Where-Object {$theHash["$_"] -eq 'mean'}
如果我有一个散列 table 比如..
$theHash = @{"dog"="mean"; "cat"="nice";"bird"="annoying"}
我可以通过以下方式获取值的键:
$theHash."dog"
如何反向操作?我想输入类似 "mean" 的内容并得到 "dog" 作为输出?所以,如果我只知道 "mean",我如何从中得到 dog?
$theHash.keys | Where-Object {$theHash["$_"] -eq 'mean'}