• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3701
  • Last Modified:

Active Directory Query for All Active, Email-enabled Users

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
leatherleaf
Asked:
leatherleaf
2 Solutions
 
Jon BrelieSystem ArchitectCommented:
What version of Exchange are you running?
0
 
leatherleafAuthor Commented:
2010
0
 
Jon BrelieSystem ArchitectCommented:
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
 
chuckmcculloughCommented:
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
 
Premkumar YogeswaranCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now