Solved

Querying AD for name

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

I have put this article together as i needed to get all the information that might be available already into one general document that could be referenced once without searching the Internet for the different pieces. I have had a few issues where…
Microsoft has released remote PowerShell capabilities to all commercial Office 365 customers. So you can be controlled via PowerShell and not from the Office 365 admin center Download Windows PowerShell Module for Lync Online http://www.micros…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now