(New-Object DirectoryServices.DirectorySearcher("(&(objectCategory=group)(name=Domain Admins))")) .FindAll().Properties['Member']
Working better with output: (function from https://petri.com/expanding-active-directory-searcher-powershell/)
Function Convert-ADSearchResult {
[cmdletbinding()]
Param(
[Parameter(Position = 0,Mandatory,ValueFromPipeline)]
[ValidateNotNullorEmpty()]
[System.DirectoryServices.SearchResult]$SearchResult
)
Begin {
Write-Verbose "Starting $($MyInvocation.MyCommand)"
}
Process {
Write-Verbose "Processing result for $($searchResult.Path)"
#create an ordered hashtable with property names alphabetized
$props = $SearchResult.Properties.PropertyNames | Sort-Object
$objHash = [ordered]@{}
foreach ($p in $props) {
$value = $searchresult.Properties.item($p)
if ($value.count -eq 1) {
$value = $value[0]
}
$objHash.add($p,$value)
}
new-object psobject -property $objHash
}
End {
Write-Verbose "Ending $($MyInvocation.MyCommand)"
}
}
^ paste that in the console to use the function
E.g. do a description audit
(New-Object DirectoryServices.DirectorySearcher("(&(objectCategory=user)(|(description=*pass*)(comment=*pass*)(note=*pass*)))")).FindAll() | Convert-ADSearchResult | Select adspath, description, comment, note, when* | out-gridview