Link to home
Start Free TrialLog in
Avatar of Angeal
Angeal

asked on

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

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.
Avatar of footech
footech
Flag of United States of America image

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

Avatar of Angeal
Angeal

ASKER

Awesome! Thanks footech, and for responding so quickly!
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

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.
Avatar of Angeal

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of Angeal

ASKER

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.