Active Directory Query

Posted on 2012-03-13
Last Modified: 2012-03-13
I need to run a query in Active Directory that will retrieve user's first name, last name and their account login name and export it to a csv file.
Question by:jduclosjduclos
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
LVL 27

Expert Comment

ID: 37714861
I would use powershell and the free Quest cmdlets

get-qaduser -sl 0 | Select FirstNAme, LastName, Samaccountname | Export-csv c:\temp\users.csv -notype
LVL 57

Accepted Solution

Mike Kline earned 500 total points
ID: 37714862
Lots of great ways

I like adfind (free)

adfind -default -f "&(objectcategory=person)(objectclass=user)" givenname sn samaccountname -csv -nodn > c:\users.csv

adinfo is a really nice free GUI tool

other methods include powershell, dstools, vbscript, csvde, and there are more.



Expert Comment

ID: 37715077
Using the native 2008 R2 AD cmdlets:

get-aduser -identity "xxxxxxx" -properties * | Select-Object samAccountName,givenname,surname | Export-CSV c:\temp\userid.csv
LVL 26

Expert Comment

by:Leon Fester
ID: 37715258
I'm a ldifde and csvde man myself, both are tools from Microsoft and available in the Windows resource kit

ldifde -f Exportuser.ldf -d "dc=Export,dc=com" -p subtree -r "(&(objectCategory=person)(objectClass=User)(givenname=*))" -l "cn, sAMAccountName"

ldifde -f Exportuser.ldf -d "dc=Export,dc=com" -p subtree -r "(&(objectCategory=person)(objectClass=User)(givenname=*))" -l "givenName, sn, sAMAccountName"

CSVDE -f export3.csv -l "cn, samAccountName"
CSVDE -f export3.csv -l "givenName, sn, samAccountName"

Author Closing Comment

ID: 37715592
Thank you!!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

695 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