Solved

Export Users and Attributes from Active Directory on 2003

Posted on 2006-11-01
14
976 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:SeanUK777
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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 

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:SeanUK777
SeanUK777 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…

733 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