Solved

Querying AD for name

Posted on 2009-03-30
4
210 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
4 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 63 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
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 configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now