Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Export Users and Attributes from Active Directory on 2003

Posted on 2006-11-01
14
Medium Priority
?
984 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 1000 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

927 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