Solved

Powershell: Export active users' firstname, lastname & email address to CSV

Posted on 2013-02-06
10
9,675 Views
Last Modified: 2013-02-12
If possible, can someone please provide a Powershell script that will export active users' first name, last name and email address to a csv file?

We are running our Domain controllers on Server 2003 and please no 3rd party cmdlets if possible.


Thanks in advance,

A.
0
Comment
Question by:Angeal
  • 3
  • 3
  • 2
10 Comments
 
LVL 39

Expert Comment

by:footech
ID: 38860287
This will do what you asked.  Email address can be a bit tricky depending on whether you have multiple, etc.  This will just report the main one that is configured in the emailAddress attribute.  Requires PS 2.0 to be installed.
import-module activedirectory
Get-ADUser -filter * -properties emailAddress | Select givenName,surName,emailAddress | Export-CSV c:\temp\userlist.csv -notype

Open in new window

0
 

Author Comment

by:Angeal
ID: 38860346
Awesome! Thanks footech, and for responding so quickly!
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38860360
ActiveDirectory module requires the 2008R2 AD Web Services. That is the reason the Quest AD modules are there - and they should be used, as they make life easier. With those, it is similar to above:
Get-QADUser | select FirstName, LastName, email | Export-Csv -NoType C:\temp\users.csv

Open in new window

0
 
LVL 39

Expert Comment

by:footech
ID: 38860442
Qlemo is right.  I'm getting so used to having 2008R2 domain controllers that I don't think about it anymore.  Sorry for the misinformation.  You would need at least one DC running 2008R2 (or higher) to use the Microsoft AD cmdlets.  Feel free to request attention to this question to re-open and assign points appropriately.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Angeal
ID: 38860615
Hi Qlemo,

Please re-open the question.

We don't have ADWS and currently don't have a W2008R2 DC.

How do I implement Quest? Does something need to be installed on one of the DC's to use Quest cmdlets? I'm fairly new to using Powershell.

Thanks to you both,

A.
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 38860729
One other (non-PowerShell) option that I'll propose in case it gets you out of a pinch.  Using Active Directory Users and Computers, you can create a Saved Query (a custom query with the criteria being Firstname, Lastname, and Emailaddress present would suffice).  Select which columns you want (unfortunately you can't remove the "Name" column), then export the list and choose comma delimited.  Open in Excel and remove the "Name" column, then resave.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38860739
Quest is a free PowerShell module you have to import on the machine you are using for running the PS script. Download at http://www.quest.com/powershell/activeroles-server.aspx .
One way to get the Snap-In loaded (after having installed it) is by issueing
          Add-PSSnapin Quest.ActiveRoles.ADManagement
in your PS session.
0
 

Author Comment

by:Angeal
ID: 38864002
Qlemo,

So nothing needs to be installed on the actual DC? Interesting. I'm definitely going to look into Quest if that's the case.

Footech,

Your non-Powershell option did the trick. Just what I needed.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn about cloud computing and its benefits for small business owners.
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
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 …

705 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

19 Experts available now in Live!

Get 1:1 Help Now