Solved

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

Posted on 2013-02-06
10
11,323 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 69

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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
 

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 69

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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 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…

770 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