Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-02-06
10
Medium Priority
?
17,064 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 41

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 71

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
Office 365 Training for Admins - 7 Day Trial

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.

 
LVL 41

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 41

Accepted Solution

by:
footech earned 2000 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 71

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

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

704 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