?
Solved

Exporting users and email addresses

Posted on 2018-02-09
7
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
Comment
Question by:WellingtonIS
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:Dustin Saunders
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

Open in new window

0
 

Author Comment

by:WellingtonIS
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

by:Dustin Saunders
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

Open in new window

0
Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

 

Author Comment

by:WellingtonIS
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

by:
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

Open in new window


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

Open in new window


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

Author Closing Comment

by:WellingtonIS
ID: 42463889
Thanks!  that worked great!
0
 
LVL 16

Expert Comment

by:Dustin Saunders
ID: 42463890
No problem, glad to help.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Join & Write a Comment

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

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.

Join & Ask a Question