title: powershell hashtable.containsValue returns false, but looping the values gets a match?
body: <p>So I'm trying to create a function in powershell that nests all the groups a user is member of in ad. I map the groups into a hashtable, with the common name from AD as the value.</p>
  
  <p>This goes well, and the function returns a hashtable containing all my groups. but when I query it using 
  <code>$group = "IT-Avd"
      $groups.ContainsValue($group)</code></p>
  
  <h2>It returns false -- but when I loop over the values and do the same comparison, I do get a match! what's going on??</h2>
  
  <pre><code>function get-groupmemberships ($workDN){
      $ADobj = [ADSI]"LDAP://$workDN"     
      foreach ($currGroup in $ADobj.memberOf.Value){
          if (!($currGroup -eq $null)){
              #Write-Host "displayN:" $grpDetails.Name " | dn:" $currGroup " | "
              if(!$groups.ContainsKey($currGroup)){
                  $grpDetails = [ADSI]"LDAP://$currGroup"
                  $groups.Add($currGroup,$grpDetails.Name)
                  #Write-Host "Adding new pair, " $grpDetails.Name " | " $currGroup
                  get-groupmembership $currGroup
              }
          }
      }
      return $groups
  }
  
  function get-DN ($SAMToFetch){
      $strFilter = "(samAccountName=$SAMToFetch)"
      $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
      $objSearcher.Filter = $strFilter
      $objPath = $objSearcher.FindOne()
      if($objPath){
          $objFound = $objPath.GetDirectoryEntry()
          $objDN = $objFound.distinguishedName
          return $objDN}
      else{ 
          return $false
      }
  }
  
  $groups = @{}   
  write-host "Start search:",(Get-Date -Format T),",",(get-Date -format fff)
  $group = "IT-Avd"
  $memberOf = get-GroupMemberships (get-DN jslonsetteig)
  $groups.ContainsValue($group)
  foreach( $val in $groups.Values){if ($val -eq $group){Write-Host $val "&lt;--It does seem to be there..."}}
  
  write-host "End search:",(Get-Date -Format T),",",(get-Date -format fff)`
  </code></pre>