I do a lot of work with Active Directory. One of the common tasks with AD is searching. I saw a question about searching an OU for groups with "exec" in their name. There are at least two approaches – a script and a cmdlet that can be used
$root = [ADSI]"LDAP://OU=AllGroups,DC=starking,DC=org"
$search = [System.DirectoryServices.DirectorySearcher]$root
$search.Filter = "(&(objectcategory=group)(cn=*exec*))"
$result = $search.FindAll()
foreach ($group in $result)
This is a standard search. Set the root of the search, set a filter and run findall(). The filter is looking for groups with "exec" in the name and is case insensitive.
get-qadgroup -LdapFilter "(&(objectcategory=group)(cn=*exec*))" -SearchRoot "OU=AllGroups,DC=starking,DC=org"
The cmdlet is even easier to use and code. Both give the same results. If you can’t use the Quest cmdlets for any reason then the script is an alternative approach.