Kae Travis

Use PowerShell ADSI to Search Groups in Active Directory

[catlist name=”PowerShell ADSI and Active Directory” conditional_title=”Other Posts in this Series:” numberposts=5 pagination=yes customfield_orderby=”series_post_order” order=”asc”]

This post provides a simple example of how we can use PowerShell ADSI to search groups in Active Directory.  You may wish to further optimise this by using LDAP filters.

#only groups
$objSearcher=[adsisearcher]'(&(objectCategory=group))'
$objSearcher.PageSize = 200

#specify properties to include
$colProplist = "name"
foreach ($i in $colPropList) { $objSearcher.PropertiesToLoad.Add($i) | out-null } 
	
$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{
    #group name
    $groupname = ($objResult.Properties).name    
    write-host $groupname  		
}

 

Use ADSI to Search Groups in Active Directory
Use PowerShell ADSI to Search Groups in Active Directory

Leave a Reply