title: powershell - find which hashtable key has value
body: <p>I hardcoded a hashtable </p>
  
  <pre><code>$myHash = @{
      Americas = "US","CA","MX" #,...
      Asia = "CN","JP" #,...
      Europe = "PL","GB" #,...you get the idea
  </code></pre>
  
  <p>Now I'm going thru inputs in a foreach loop where I set </p>
  
  <pre><code>$country = $_.country #The 2-letter country code
  </code></pre>
  
  <p>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 <code>Americas</code>,<code>Asia</code>, or <code>Europe</code> (i.e $myVar = ??? prints/outputs "America"). I don't know powershell so I don't know the specific syntax to accomplish this</p>
  
  <p>it looks like <code>.containsValue()</code> works on the hashtable itself, not a key of a hashtable. I with only 3 keys, I could just have 3 if statements </p>
  
  <pre><code>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()){...}
  </code></pre>