Solved

What is the correct syntax to use for CSVDE to get the desired output

Posted on 2010-11-22
13
922 Views
Last Modified: 2012-05-10
How can I export data from large A D tree into a csv file. The OU that I need exported is PHD\Users and Groups\EMEA\United Kingdom\London The Domain is Called Global.com I need logonname, homedrive and home drive path. I know that I can get the data by using the csvde command and output to a csv file
0
Comment
Question by:EMEA iOps
  • 7
  • 5
13 Comments
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34187552

Hello there,
csvde -r "(&(objectClass=users)(objectCategory=person))" -d "OU=London,OU=United Kingdom,OU=EMEA,OU=Users and Groups,OU=PHD,DC=global,DC=com" -l "sAMAccountName,homeDrive,homeDirectory" -f YourFile.csv

Open in new window

HTH

Chris
0
 
LVL 1

Expert Comment

by:amieldar
ID: 34187760
0
 

Author Comment

by:EMEA iOps
ID: 34187799
Hi Chris, I eneterd your suggested string, however it is not producing the desired output as I get after typing the command: Connecting to "(null)" login in as current user (I've got admin rights) using SSPI exporting directory to myfile.csv Searching for entries... Writing out entries No entries found The command has completed successfully. There are lots of objects in the container
0
 
LVL 70

Assisted Solution

by:Chris Dent
Chris Dent earned 75 total points
ID: 34187821

It's likely this path is not correct:

"OU=London,OU=United Kingdom,OU=EMEA,OU=Users and Groups,OU=PHD,DC=global,DC=com"

CSVDE doesn't validate it, if the path is not correct it will simply say it found nothing.

With that in mind, the path above translates to:

global.com/PHD/Users and Groups/EMEA/United Kingdom/London

Is that correct?

If unsure, pop open ADSIEdit, browse to the folder you want, open Properties and look at the DistinguishedName property, that's the value we must use.

Chris
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34187840

Incidentally, if you have a lot of tasks like this to do, PowerShell with Quests AD CmdLets would simplify the interface for you (it will tell you if the path is wrong with "A referral was returned from the server").

Chris
0
 

Author Comment

by:EMEA iOps
ID: 34187871
Hi Chris,
Thanks for your answer the path is right the Canonical name of object is:
global.com/PHD/Users and Groups/EMEA/United Kingdom/London
Any ideas?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 70

Assisted Solution

by:Chris Dent
Chris Dent earned 75 total points
ID: 34187936

Hmm well that's helpful of it. That should work.

-r is the filter and tells it you want user accounts (drops contacts and computers, caught by either condition on its own).
-d is the Search Root, and should work with what we have above
-l is the list of attributes (but we're not getting that far)

Lets drop the filter for now, and lets move up a level in the structure:
csvde -d "OU=United Kingdom,OU=EMEA,OU=Users and Groups,OU=PHD,DC=global,DC=com" -l "sAMAccountName,homeDrive,homeDirectory" -f YourFile.csv

Open in new window

Chris
0
 

Accepted Solution

by:
EMEA iOps earned 0 total points
ID: 34188052
Excellent the above syntax produced the desired output. Thanks for your help
0
 

Author Comment

by:EMEA iOps
ID: 34206891
I do also need to get their primary SMTP email address. What would be the sintax for it?
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34206921

You just need the mail field, that holds the primary address.
csvde -d "OU=United Kingdom,OU=EMEA,OU=Users and Groups,OU=PHD,DC=global,DC=com" -l "sAMAccountName,homeDrive,homeDirectory,mail" -f YourFile.csv

Open in new window

Chris
0
 

Author Comment

by:EMEA iOps
ID: 34206947
Chris, you're a star mate.
0
 

Author Closing Comment

by:EMEA iOps
ID: 34221174
Thanks for your comments
0
 

Author Comment

by:EMEA iOps
ID: 34293418
Hi I have got a file exported, now I need to import the data once the home directory path has been updated. Can anyone help with the syntax: csvde -i -f filename.csv
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Organizations create, modify, and maintain huge amounts of data to help their businesses earn money and generally function.  Typically every network user within an organization has a bit of disk space to store in process items and personal files.   …
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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

21 Experts available now in Live!

Get 1:1 Help Now