I hardcoded a hashtable
$myHash = @{
Americas = "US","CA","MX" #,...
Asia = "CN","JP" #,...
Europe = "PL","GB" #,...you get the idea
Now I'm going thru inputs in a foreach loop where I set
$country = $_.country #The 2-letter country code
Now I want to find if that country code maps to Americas, Asia, or Europe (aka which key holds that value). How can I find which key contains the 2-letter country code so I can have can have a variable/output that will say either Americas,Asia, or Europe (i.e $myVar = ??? prints/outputs "America"). I don't know powershell so I don't know the specific syntax to accomplish this
it looks like .containsValue() works on the hashtable itself, not a key of a hashtable. I with only 3 keys, I could just have 3 if statements
if($myHash["Americas"].containsValue()){
$region = "Americas"
#or even better if I could get "Americas" dynamically by something like
#$region = myHash.returnKeyThatContainsValue($country)
}
if($myHash["Asia"].containsValue()){...}
if($myHash["Europe"].containsValue()){...}