Solved

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

Posted on 2013-02-06
10
13,777 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
10 Comments
 
LVL 40

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 70

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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 40

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
 

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 40

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 70

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
A hard and fast method for reducing Active Directory Administrators members.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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