Solved

Querying AD for name

Posted on 2009-03-30
4
215 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

Independent Software Vendors: 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

In-place Upgrading Dirsync to Azure AD Connect
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to 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…
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…

730 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