Author Posts

August 31, 2014 at 6:55 pm

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.

August 31, 2014 at 8:31 pm

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

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

# do it now