Solved

Export Users and Attributes from Active Directory on 2003

Posted on 2006-11-01
14
970 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
  • 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

13 Experts available now in Live!

Get 1:1 Help Now