# Need help accessing hash table returned by recordset

**URL:** <https://forums.powershell.org/t/need-help-accessing-hash-table-returned-by-recordset/3036>\
**Category:** PowerShell Help\
**Created:** [August 31, 2014, 1:25pm UTC](https://forums.powershell.org/t/need-help-accessing-hash-table-returned-by-recordset/3036 "2014-08-31T13:25:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![don-smith-75054](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@don-smith-75054](https://forums.powershell.org/u/don-smith-75054)\
**Post date:** [August 31, 2014, 1:25pm UTC](https://forums.powershell.org/t/need-help-accessing-hash-table-returned-by-recordset/3036/1 "2014-08-31T13:25:15Z")

</div>

Hello All,

I need some help.  
I am running an AD search and I receive the output of the recordset in a variable.  
When I print out the variable it shows that the variable contains an unnamed hash table.  
I have tried everything I can think of to access the value in the hash table to make a comparison to.

Ultimate goal. verify the system in the variable $strTargetHost is found in AD.

code snippet - psudo code

inside a for loop containing the names of the host systems I want to search for

# retrieve the results of the Search

$searchResult = $objRecordSet.fields.item(“name”) | Select-Object Name,Value

```
      Write-Host "DEBUG: searchResult = " $searchResult
  

      if ($objRecordSet.fields.item("name") -match $strTargetHost) { #latest iteration of attempts to access the Value data returned in the hash table array

         write out the data to a file
      }

  When I print out the contents of $searchResult = @{Name=name, Value=99W7XLN1}

```

Question: How can I access the array that is being stored in $searchResult?  
How can I compare the Value ( in this case “99W7XLN1” to desired host ($strTargetHost) which is the same value 99W7XLN1

Any assistance you could provide would be greatly appreciated.  
Thanks,

---

<div class="post-metadata">

**Author:** ![don-smith-75054](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@don-smith-75054](https://forums.powershell.org/u/don-smith-75054)\
**Post date:** [August 31, 2014, 3:01pm UTC](https://forums.powershell.org/t/need-help-accessing-hash-table-returned-by-recordset/3036/2 "2014-08-31T15:01:57Z")

</div>

Never mind fellas, I finally figured it out after hours of trial and error.

if (( $searchResult.value) -contains $strTargetHost) {

# do it now

}

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:47pm UTC](https://forums.powershell.org/t/need-help-accessing-hash-table-returned-by-recordset/3036/3 "2024-05-16T20:47:37Z")

</div>


