Solved

Querying AD for name

Posted on 2009-03-30
4
216 Views
Last Modified: 2012-05-06
I want to create a query using dsquery that outputs to a txt file the username and name of all users in AD.

Any help greatly appreciated.
0
Comment
Question by:lgmmiller
[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
4 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 63 total points
ID: 24023240
use this as a start maybe

The client request was to get ALL user information and fields from AD without OUs and groups.

They are most definitely held in active directory. The easy way to determine this would be to run the following command.

dsquery user -samid * | dsget user -fn -ln -mi

AD Field sn = Last Name

AD Field givenName= First Name

AD Field initials = Middle Initial


I hope this helps !
0
 
LVL 57

Assisted Solution

by:Mike Kline
Mike Kline earned 62 total points
ID: 24023257
I'd like to suggest a great tool called adfind by MVP Joe Richards
http://www.joeware.net/freetools/tools/adfind/index.htm
adfind -default -f  "&(objectcategory=person)(objectclass=user)" name samaccountanme -nodn -csv >  c:\Allusers.csv
That will output it all to csv file.
Thanks
Mike
0
 
LVL 1

Expert Comment

by:Joemonkey
ID: 24091393
I have this in a batch file and run it weekly or so.  It gives their first name, last name, and logon (or samaccountname if you prefer).  You'll obviously have to edit the OU line

dsquery user -name * "OU=All Users,DC=domain,dc=net" -limit 5000 | dsget user -fn -ln -samid > \\server\share\users.txt

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Here's a look at newsworthy articles and community happenings during the last month.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

726 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