Useful scripts/commands to find specific users

Goal is to find users with the following criteria

1. UM enabled user AND

2. TelephoneNumber starting with +1 AND

3. Mailbox residing in UM server named “EXCHANGE2007”

The LDAP query to be entered under the advanced tab is

(&(objectclass=user)(msexchumenabledflags=831)(telephonenumber=+1*)(msexchhomeservername=*exchange2007*))

To see more columns you have to do the following.

1. Click “find now”

2. Once the results appear, click on “view” à “choose columns”

3. Add appropriate column names as desired

Now if you are looking to export this to a file we have to use the ldifde utility from command line.

The command is

ldifde –d “dc=KAUSHAL,dc=COM” –f c:\output.txt –r “(&(objectclass=user)(msexchumenabledflags=831)(telephonenumber=+1*)(msexchhomeservername=*EXCHANGE2007*))” -l “telephonenumber, mailnickname, msexchhomeservername, displayname”

(ldifde is a built-in tool in Windows Server 2008)

The above command will output the list of users with their telephone number, nick name, exchange server name and their full name. The output is not formatted so you have to manually format it for better visual experience.

In case of finding users who are not UM enabled, simply add a ! in front of the msexchumenabledflags parameter.

Have fun!!