Solved

Export Users and Attributes from Active Directory on 2003

Posted on 2006-11-01
14
979 Views
Last Modified: 2009-07-29
Hello

I would like to export easily export a list of all users from Active Directory on Windows server 2003.  I tried this command NET USERS /DOMAIN >USERS.TXT  but this only exports the actual users.  But I need more information like what OU they are in and some attributes from their user profile like their profile path.

Is there a way to do this?  And export this to a file?

Thanks

Mike
0
Comment
Question by:MickaelE
[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
  • 7
  • 3
  • 2
14 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 250 total points
ID: 17848621
You can get basic details with

dsquery USER | dsget USER -options

where -options are some of these (see these by typing dsget USER -?)

e.g.

dsget USER -ln -fn -display -acctexpires

When you are happy with it redirect to a file with >users.txt

Lotsof options with DSQUERY and DSUSER

-dn                     Shows the DN of the user.
-samid                  Shows the SAM account name of the user.
-sid                    Shows the user Security ID.
-upn                    Shows the user principal name of the user.
-fn                     Shows the first name of the user.
-mi                     Shows the middle initial of the user.
-ln                     Shows the last name of the user.
-display                Shows the display name of the user.
-empid                  Shows the user employee ID.
-desc                   Shows the description of the user.
-office                 Shows the office location of the user.
-tel                    Shows the telephone number of the user.
-email                  Shows the e-mail address of the user.
-hometel                Shows the home telephone number of the user.
-pager                  Shows the pager number of the user.
-mobile                 Shows the mobile phone number of the user.
-fax                    Shows the fax number of the user.
-iptel                  Shows the user IP phone number.
-webpg                  Shows the user web page URL.
-title                  Shows the title of the user.
-dept                   Shows the department of the user.
-company                Shows the company info of the user.
-mgr                    Shows the user's manager.
-hmdir                  Shows the user home directory.
                        Displays the drive letter to which the
                        home directory of the user is mapped
                        (if the home directory path is a UNC path).
-hmdrv                  Shows the user's home drive letter
                        (if home directory is a UNC path).
-profile                Shows the user's profile path.
-loscr                  Shows the user's logon script path.
-mustchpwd              Shows if the user must change his/her password
                        at the time of next logon. Displays: yes or no.
-canchpwd               Shows if the user can change his/her password.
                        Displays: yes or no.
-pwdneverexpires        Shows if the user password never expires.
                        Displays: yes or no.
-disabled               Shows if the user account is disabled
                        for logon or not. Displays: yes or no.
-acctexpires            Shows when the user account expires.
                        Display values: a date when the account expires
                        or the string "never" if the account never expires.
-reversiblepwd          Shows if the user password is allowed to be
                        stored using reversible encryption (yes or no).
<UserDN>                Required. DN of group to view.
-memberof               Displays the groups of which the user is a member.
0
 
LVL 10

Expert Comment

by:Seelan Naidoo
ID: 17848886
dont forget to pipe to either a text (.txt) or excel (.xls) file by adding the following after the commands listed above..


 > c:\user.txt

or

 > c:\users.xls
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17849589
As I said above :-)  Exporting text to an XLS will work but it isn't a true XLS file just a text file called .XLS.  You could as easily open the text file in Excel if needed.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:MickaelE
ID: 17849936
How long should this take to run.  I ran dsget USER -ln -fn -display -acctexpires and it is taking ages?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17849964
How many users are we talking about.  It will dump all the users into a temporary file effectively then pipe that into dsget USER.  Did you run it as shown:

dsquery USER |dsget USER -ln -fn -display -acctexpires

Otherwise yes it will just sit there... actually looks like I didn't post the first bit into the second example, sorry!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17849970
You can of course limit it to certain OU downward etc. too if needed with paramaters on the dsquery command.
0
 

Author Comment

by:MickaelE
ID: 17850100
this is what I did.  I used the second example.  What is the switch for OU?  I did not see it in the list.

Mike
0
 

Author Comment

by:MickaelE
ID: 17850115
I am trying to output 200 users.  What is the syntax for that it seems to limit at 100.

Thanks

0
 
LVL 10

Assisted Solution

by:Seelan Naidoo
Seelan Naidoo earned 250 total points
ID: 17850128
c:\>dsquery user -limit 0 | dsget user -ln -fn -acctexpires > c:\users.txt

or

c:\>dsquery user -limit 0 | dsget user -ln -fn -acctexpires > c:\users.xls
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17850132
Have a look at dsquery -? for the OU syntax, sorry not on a machine I can check it for myself at the moment but think you just specify, i.e.

DSQUERY OU=x.DC=yourdomain.DC=com USER ..... but check it please!

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17850144
Just checked on a different machine, to unlimit the output use

dsquery user -limit n

if you make n it is umlimited or make it 500 or whatever.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17850165
Oops, didn't see your post in the middle SeanUK...

I had the syntax back to front for selecting an OU too:

dsquery USER ou=x,DC=x,DC=com | dsget user  ...

Steve
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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