[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 975
  • Last Modified:

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

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
EMEA iOps
Asked:
EMEA iOps
  • 7
  • 5
3 Solutions
 
Chris DentPowerShell DeveloperCommented:

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
 
EMEA iOpsAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Chris DentPowerShell DeveloperCommented:

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
 
Chris DentPowerShell DeveloperCommented:

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
 
EMEA iOpsAuthor Commented:
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
 
Chris DentPowerShell DeveloperCommented:

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
 
EMEA iOpsAuthor Commented:
Excellent the above syntax produced the desired output. Thanks for your help
0
 
EMEA iOpsAuthor Commented:
I do also need to get their primary SMTP email address. What would be the sintax for it?
0
 
Chris DentPowerShell DeveloperCommented:

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
 
EMEA iOpsAuthor Commented:
Chris, you're a star mate.
0
 
EMEA iOpsAuthor Commented:
Thanks for your comments
0
 
EMEA iOpsAuthor Commented:
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

Industry Leaders: 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!

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now