Solved

Active Directory Query for All Active, Email-enabled Users

Posted on 2014-04-03
5
2,621 Views
Last Modified: 2014-04-08
I need to find a way to query Active Directory that will give me a list of all users who are NOT disabled and have an email address listed. Dsquery seems to only allow you to search for disabled users, not enabled users only, and I can't seem to find a way to do this using the AD GUI. Any thoughts? Someone must have needed to do this before.
0
Comment
Question by:leatherleaf
5 Comments
 
LVL 16

Expert Comment

by:Enphyniti
Comment Utility
What version of Exchange are you running?
0
 

Author Comment

by:leatherleaf
Comment Utility
2010
0
 
LVL 16

Assisted Solution

by:Enphyniti
Enphyniti earned 250 total points
Comment Utility
Forgot to ask, are you looking for AD user objects with email addresses defined, or users that have exchange mailboxes?

If you're looking for the emailaddress attribute of the AD user object, then something like this powershell will give you what you need:

import-module activedirectory
Get-ADUser -filter * -properties emailaddress, enabled| ?{($_.emailaddress -ne $null) -and ($_.enabled -eq "True")}
0
 
LVL 3

Expert Comment

by:chuckmccullough
Comment Utility
If you want a GUI solution you might consider products like SystemTools Hyena:

http://www.systemtools.com/hyena/

It has a default query for All Disabled Users, but you can copy that query and with one change make an All Enabled Users. You'll be able to customize this query to add any fields you want it to display, such as E-Mail, etc. From there simply run it with a right-click menu option and sort on the E-Mail column.

Better yet, you can add this to your new All Enabled Users query: (mail=*), and when you run it will only return enabled users with a value in the E-Mail attribute.

Full Disclosure: I work for SystemTools Software (which also means I can help if you decide to try it and have any questions).
0
 
LVL 17

Accepted Solution

by:
Premkumar Yogeswaran earned 250 total points
Comment Utility
Hi,

Run the below command in command prompt from any domain controller orelse any member server have support tool installed.

Dsquery * -filter "&(objectCategory=user)(!UserAccountControl:1.2.840.113556.1.4.803:=2)(mail=*)" -attr name samaccountname mail  > c:\temp\file.txt 

Open in new window


Regards,
Prem
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is my first article in EE and english is not my mother tongue so any comments you have or any corrections you would like to make, please feel free to speak up :) For those of you working with AD, you already are very familiar with the classi…
Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now