Link to home
Start Free TrialLog in
Avatar of narce100
narce100

asked on

Domain users list

I need to print a list of all domain users in AD can someone help me do this?

Thank You.
Avatar of rstjean
rstjean
Flag of Canada image

download http://download.sysinternals.com/Files/AdExplorer.zip

Then there is a work around to export the list

To quote "auteri" here http://forum.sysinternals.com/active-directory-explorer_topic22035_post116397.html

I found a way to use and export the AD Explorer query to text.

1. Create a query in ADExplorer
2. Copy ADExplorer query string (Just Under Value field)
3. Open Active Directory users and computers (dsa.msc)
4. Create new query under "Saved Queries"
5. Choose Define Query > Find "Custom Search" > Advanced Tab
6. Enter LDAP Query > Paste ADExplorer query string
7. Save query
8. Export with: Export List

Its a workable solution altough having a export button in ADExplorer would be better.
Mark, if you read this, please put export in there with a xml or csv version (or even better both).
I would say dstools would be the easiest, below is a rough command to do it, but it would be a batch file to copy users samid, lastname and firstname to a txt file.

dsquery user "cn=users,ou=users,dc=company" | dsget user -samid -ln -fn >> users.txt
ASKER CERTIFIED SOLUTION
Avatar of Mike Kline
Mike Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you can do this by following command

NET USERS /DOMAIN >c:\user.txt (the command generate a text file on root of c: with required information)

NET ACCOUNTS /DOMAIN>c:\account.txt (for domain accounts)

NET config server /DOMAIN>c:\server.txt (for domain servers)
Try this following scripts:
Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "User Name"

objExcel.Cells(1, 2).Value = "Full Name"

objExcel.Cells(1, 3).Value = "Description"

 

strDomain = InputBox ("Enter Domain Name")

Set DomObj = GetObject("WinNT://" & strDomain ) 

DomObj.Filter = Array("User") 

For Each objUser In DomObj 

objExcel.Cells(intRow, 1).Value = objUser.Name

objExcel.Cells(intRow, 2).Value = objUser.FullName

objExcel.Cells(intRow, 3).Value = objUser.Description

intRow = intRow + 1

Next 

 

objExcel.Range("A1:C1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

Open in new window

Avatar of narce100
narce100

ASKER

I followed the link and did some modifications and after testing a few times I got what I wanted