Link to home
Start Free TrialLog in
Avatar of anupli
anupli

asked on

how to export user list from active directory windows 2003

how to export user list from active directory windows 2003
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

You can use the "dsquery user"command to achieve this. See below link for syntax
https://technet.microsoft.com/en-ca/library/cc725702.aspx

Will.
ASKER CERTIFIED SOLUTION
Avatar of Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Flag of United Kingdom of Great Britain and Northern Ireland 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
So an example will look like below...

dsquery user -name * > "c:\ADUsers.csv"

Open in new window


Pretty easy.

Will.
Avatar of anupli
anupli

ASKER

Thank you for your inputes
When I run below command I am getting error as mentioned below

C:\>dsquery user -name * > "c:\ADUsers.csv"
Dsquery has reached the default limit of 100 results to display; use the -limit option to
display more results.


If I want to get usernames under particular group and in that too if I want to export details mentioned in the description field. What would be the command to get this output. Please suggest the path forward.
Or you can use the old csvde command
CSVDE -f adusers.csv
http://www.computerperformance.co.uk/Logon/Logon_CSVDE_Export.htm

The only thing that you can't export is the password.

Dan
You can do this via a powershell script like this:

Select-Object -Property Name,SamAccountName,Description,EmailAddress,LastLogonDate,Manager,Title,Department,whenCreated,Enabled,Organization | Sort-Object -Property Name | ConvertTo-CSV

Alternate: hyena is a great tool I've used in previous client environments.
If you are on Windows Server 2003 and there are no Win2K8 or higher DCs then your choice is DSQUERY or CSVDE (native tools).

If you have Win2K8 DC then enable AD Web Services and use PowerShell command (i.e. get-aduser) go obtain all users info.

Another option using PowerShell would be to download PowerQuest Active Directory Roles which is free and works with Windows Server 2003.  You can then use PowerShell command get-qaduser.  Download the software from:  http://software.dell.com/products/activeroles-server/powershell.aspx

Lastly, your only other option would be to use third-party software such ones from Dell, ManageEngine,etc.
What am I missing?

Start - Admin Tools - ADUC - Expand Domain - right click Users - Export List.

That does it for me.
You sure could, however, it is very limited in what it returns (ie Fqdn, alias, account name, etc).
dsquery -limit 0 filter....
But using CSVDE is a good option as pointed out above too, it will output most of AD to a CSV file.

You can use powershell as well

Get-ADUser -Filter * -Properties mail, name| Select mail, name|export-csv users.csv

That will get the users name and email address into a CSV, remove "mail" and only get users names (first/last), for userID's use "samaccountname" instead of name.
-rich
Use my original post but add -limit 0 at the end see below...
dsquery user -name * -limit 0 > "c:\ADUsers.csv"

Open in new window


Will.
Start - Admin Tools - ADUC - Expand Domain - right click Users - Export List.

You sure could, however, it is very limited in what it returns (ie Fqdn, alias, account name, etc).

But it answers the original question.  <g>.
Going to the OU to get a list of users is a problem when all the users aren't in the same OU.   You could go to each OU that contains users and export the list for each one, but that's a pain.

You can do a custom LDAP query to get a list of users. Then, customize the view settings to see the columns you want (Display name, user name, email address, etc.) by clicking on View > Add/Remove Columns.  When you have the view settings the way you like them, right click the query name and then click export.

This page has some screenshots on how to set up a custom query to see all users:
http://anandthearchitect.com/2008/07/02/list-all-active-users-in-a-domain/

Basically, the steps are:
1.  Open ADUC
2.  Right click "Saved Queries" and then click on "New Query"
3.  Name the query and click on "Define Query" button
4.  Select Custom Search in the "Find" drop down list.
5.  Click on the Advanced tab
6.  Paste the query you want to use into the "Enter LDAP Query" text box

The query he uses in that example is:
(&(&(objectCategory=user)(userAccountControl=512)))

This will produce a list of all active users (leaving out any disabled accounts).

If you want a list of ALL users, including disabled accounts, this query worked for me:
(&(&(objectCategory=user)))

Then, set up the column headings the way you want and right click on the query name & then click on Export.