Check the case of the name:
$allGPOs = ([adsisearcher]'(objectCategory=groupPolicyContainer)').FindAll()
# this returns nothing
$allGPOs | % { $_.Properties.gPCmachineExtensionNames }
# this returns what you expect
$allGPOs | % { $_.Properties.gpcmachineextensionnames }
$allGPOs | ForEach-Object {
New-Object -TypeName PSCustomObject -Property @{
abc = $_.Properties.gpcmachineextensionnames -join ''
}
}
I'm making an assumption here that as $allGPOs.GetType()
is SearchResultCollection, and $allGPOs[0].Properties.GetType()
is SearchResultCollection, they behave slightly different than "regular" name/value pairs.