How to use dsget to export users/emails to text file?


J

john boy

hey there,

can anyone tell me the exact syntax using dsget to export
all my domain users and their emails to a text file please?

thank ya! :)
 
Ad

Advertisements

C

Cry Shultz [MVP]

-----Original Message-----
hey there,

can anyone tell me the exact syntax using dsget to export
all my domain users and their emails to a text file please?

thank ya! :)
.
John Boy,

I know that this is not for 'dsget' but there is a utility
out there called ldifde that is native to WIN2000. To get
a list of all of your user accounts with all of their
attributes you could simply go to a DC and enter the
following:

ldifde -f ADUsers.ldf -r "(objectClass=user)"

Did you want to restrict that list to simply the user
account and the corresponding e-mail address?

HTH,

Cary
 
M

Matjaz Ladava [MVP]

Or to add what Cary said a csvde tool which as ldifde exports user info in
csv format which is IMHO more user friendly and you can directly view it in
excel ;-)

--
Regards

Matjaz Ladava, MCSE, MCSA, MCT, MVP
Microsoft MVP - Active Directory
(e-mail address removed), (e-mail address removed)
http://ladava.com
 
C

Cary Shultz [A.D. MVP]

Matjaz,

You are correct. csvde is much more user-friendly than ldifde. I guess
that I learned ldifde first and have some affliction for it ;-)

I will try to be less 'biased' in the future! Thank you for catching me on
this.

Cary
 
J

john boy

Thanks all!

So, if I use CSVDE what is the syntax to export only
accounts and emails?

Thanks!
 
M

Matjaz Ladava [MVP]

csvde -f yourfile.csv -r "(&(objectCategory=Person)(objectClass=user))" -l
"sAMaccountname,mail"

--
Regards

Matjaz Ladava, MCSE, MCSA, MCT, MVP
Microsoft MVP - Active Directory
(e-mail address removed), (e-mail address removed)
http://ladava.com
 
Ad

Advertisements

J

Jason Robarts [MSFT]

I know the main question has been answered but I'll bite and talk about the
new tools. Although I like ldifde and csvde for some uses, the ds* tools
have advantages in some situations because you don't need to know as much
about LDAP and the attributes Active Directory uses to do some common tasks.

dsget will help you get the information about one object in AD. dsquery
will help you get information about multiple objects in AD.

The following is from the help of dsget:

"To find all users with names starting with "John" and display their office
numbers:

dsquery user -name John* | dsget user -office"


dsquery user domainroot -name * | dsget user -dn -samID

gave me reasonable looking results for the DN and samAccountName of the
users in my domain. I expect

dsquery user domainroot -name * | dsget user -dn -email

would give you the results you are looking for. I don't have email address
configured in my test domain to try it on. The dsquery user
domainroot -name * will output a list of DNs which dsget uses to fetch the
properties of the object will.

Even if you decide to go with csvde, I'd suggest looking at the help for
both dsquery user /? and dsget user /? to get more info about querying
users.

Jason
 
M

Matjaz Ladava [MVP]

Your commands work perfectly Jason. We just don't have in our minds......
jet. :)

--
Regards

Matjaz Ladava, MCSE, MCSA, MCT, MVP
Microsoft MVP - Active Directory
(e-mail address removed), (e-mail address removed)
http://ladava.com
 
G

Guest

Thanks Matjaz!

-----Original Message-----
csvde -f yourfile.csv -r "(&(objectCategory=Person) (objectClass=user))" -l
"sAMaccountname,mail"

--
Regards

Matjaz Ladava, MCSE, MCSA, MCT, MVP
Microsoft MVP - Active Directory
(e-mail address removed), (e-mail address removed)
http://ladava.com




.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top