ADUC MMC (Active Directory User and Computers) is a popular tool that manages Active Directory objects.
Here at Bobcares, we have seen several such Windows related queries as part of our Server Management Services for web hosts and online service providers.
Today we’ll see about using saved queries in ADUC MMC (Active Directory User and Computers).
Know more about ADUC MMC
The Saved Queries in Active Directory Users and Computers (ADUC) MMC console generally allows you to create complex LDAP filters to select Active Directory objects. Moreover, you can save these queries, edit them, and copy them to other computers.
These Saved Queries mainly help you to quickly perform common AD object administration tasks. When you are using any saved LDAP queries, the administrator can perform group operations with objects from different OUs (containers) of Active Directory.
How to Create a Saved Query in the ADUC MMC Console?
Now let’s take a look at a few typical examples of using saved LDAP queries in Active Directory Users and Computers console to search for objects.
In case, we need to display the list of active user accounts, their department names, and e-mail addresses.
1. First, open the ADUC console (dsa.msc). Then right-click Saved Queries and select New >> Query
2. In the Name box, specify the name of the saved query you would want to display in the ADUC console.
3. Specify the container (OU) in which you want to search in the Query root field. By default, the search by the query criteria is performed across the entire AD domain.
4. Click on the Define Query button, and from the Find drop-down list, select the Custom Search option.
5. Then go to the Advanced tab and copy the following LDAP query into Enter LDAP query box. This query selects enabled user account.
(&(objectcategory=person)(objectclass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))
6. Click on OK to save the changes.
7. Select the created query in the ADUC console and press F5 to build the object list. Then a list of users will appear in the right window that matches the LDAP query
8. If you wish to display the additional user attributes then open the View menu in the ADUC console and select Add/Remove Columns.
9. Now add the columns that you want.
10. The resulting list of user accounts can be saved to a CSV or TXT file for further analysis and import into Excel. For doing that, right-click on the saved query and select the Export List menu item.
Also, you can get data from AD using PowerShell and save it directly to an Excel file.
Moreover, in the ADUC console, you can create a number of different saved queries and then organize them in a tree structure. In this way, you can create a convenient collection of LDAP queries to quickly perform common AD administration tasks.
The ADUC MMC snap-in supports several modes of building Active Directory saved queries. Also, you need not specify the LDAP filter code each time instead you can create your AD query with a simple graphical wizard. Just select different attributes of AD objects and use them to search objects according to the criteria you want.
For instance, to list all Windows Server computer objects in a domain:
1. Find Computers
2. Click on the Advanced tab
3. Under Fields section -> Operating System
4. Condition must be ‘Starts with’ -> specify your criteria ‘Windows Server *‘
The wildcard is * (you can specify ‘*Server*‘). Multiple search criteria can be added to your saved query.
Now save the query and refresh the object list. As a result, the list will show all Windows Server objects in your domain.
Using LDAP Filters in PowerShell
You can use the different LDAP filters to find AD objects in the PowerShell console. Most of the cmdlets from the PowerShell Active Directory module have a special LdapFilter parameter. You would need to specify your LDAP query in this parameter. For instance,
Get-ADUser -LdapFilter "(&(objectCategory=person)(objectClass=user)(department=*Sales department*))"| ft -a DisplayName,department
The Get-ADUser, Get-ADComputer, and Get-ADGroup cmdlet are some of the specialized cmdlets and are used to find objects of a certain type – users, computers, or groups.
In case, if you don’t have an idea about the type of AD object you want, or if you need information about all types of objects, use the more common Get-ADObject cmdlet.
[Need any further assistance with Windows queries? – We are here to help you.]
Conclusion
In today’s writeup, we saw about using saved queries in ADUC MMC (Active Directory User and Computers).
0 Comments