Recipe 4.27 Importing Objects Using a CSV File

4.27.1 Problem

You want to import objects into Active Directory using a CSV file.

4.27.2 Solution Using a command-line interface

To import objects using the csvde utility, you must first create a CSV file containing the objects to add. The first line of the file should contain a comma-separated list of attributes you want to set, with DN being the first attribute. Here is an example:


The rest of the lines should contain entries to add. If you want to leave one of the attributes unset, then leave the value blank (followed by a comma). Here is a sample CSV file that would add two user objects:


Once you've created the CSV file, you just need to run cvsde command to import the new objects.

> csvde -i -f input.csv

4.27.3 Discussion

Note that each line of the CSV import file, except the header, should contain entries to add objects. You cannot modify attributes of an object or delete objects using csvde. If you have a spreadsheet containing objects you want to import, first save it as a CSV file and use csvde to import it. Using a command-line interface

To import with csvde, simply specify the -i switch to turn on import mode and -f <filename> for the file. It can also be beneficial to use the -v switch to turn on verbose mode to get more information in case of errors.

4.27.4 See Also

Recipe 4.26 for exporting objects in CSV format, and MS KB 327620 (HOW TO: Use Csvde to Import Contacts and User Objects into Active Directory)

    Chapter 3. Domain Controllers, Global Catalogs, and FSMOs
    Chapter 6. Users
    Appendix A. Tool List