Solved

# Exporting users and email addresses

Posted on 2018-02-09
Medium Priority
23 Views
Last Modified: 2018-02-09
I need to query AD to show the user and the users email address.  How can I accomplish this?
0
Question by:WellingtonIS
• 4
• 3
7 Comments

LVL 16

Expert Comment

ID: 42463868
Just an FYI, if you add in the scripting language those Experts will be able to see your question easier.

This code pulls alist of AD users and their Email Address.
Get-ADUser -Filter * -Properties EmailAddress | Select-Object Name,EmailAddress

0

Author Comment

ID: 42463871
Powershell?  Can this be set to export to CSV or XLSX? For the filter put in the OU?
0

LVL 16

Expert Comment

ID: 42463873
Yes-- Powershell is incredibly powerful for AD management.  Edit the -Path to where you want the file to export.
Get-ADUser -Filter * -Properties EmailAddress | Select-Object Name,EmailAddress | Export-Csv -Path "C:\path\to\export\users.csv" -NoTypeInformation

0

Author Comment

ID: 42463878
That worked however, I'm in a huge domain with an OU that is mine  Can I add the DN so I don't get the entire list of users?  Or even better the user name begins with wrm if I can user that.
0

LVL 16

Accepted Solution

Dustin Saunders earned 2000 total points
ID: 42463882
In the -Filter section you can specify criteria.
Get-ADUser -Filter {SamAccountName -like "wrm*"} -Properties EmailAddress | Select-Object Name,EmailAddress | Export-Csv -Path "C:\path\to\export\users.csv" -NoTypeInformation


If you want to get all users from a specific location, use -SearchBase
Get-ADUser -SearchBase "OU=Test,DC=domain,DC=local" -Filter * -Properties EmailAddress | Select-Object Name,EmailAddress | Export-Csv -Path "C:\path\to\export\users.csv" -NoTypeInformation


Just edit the DN for the starting location.  Or you can use the first one.
0

Author Closing Comment

ID: 42463889
Thanks!  that worked great!
0

LVL 16

Expert Comment

ID: 42463890
No problem, glad to help.
0

## Join & Write a Comment Already a member? Login.

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Sometimes it necessary to set special permissions on user objects.  For instance when using a Blackberry server, the SendAs permission needs to be set. I see many admins struggle with the setting that permission only to see it disappear within a few…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
###### Suggested Courses
Course of the Month6 days, 8 hours left to enroll

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

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