Logon Scripts

 

CSVDE - Import User Accounts

Introduction to CSVDE Import

The purpose of this page is to show you how to bulk import user accounts into Active Directory.  Here are scenarios where CSVDE will save you work:

  • To create hundreds of new users in a Windows Server 2003 or 2000 domain.

  • To import hundreds of NT 4.0 users into a brand new Active Directory domain.

  • To migrate directory services from Exchange 5.5 into Active Directory.

Topics for CSVDE Import

Export examples

Why begin with Export?

When you use CSVDE -i to import user accounts, you make changes that will be difficult to reverse.  For instance, you may import unsuitable usernames, but then you cannot find those users in Active Directory.  In frustration, you delete existing users as well as the imported test accounts.   In export mode, you can do no harm to Active Directory, also CSVDE -f filename.csv will help build up your understanding of the switches.

˚

Import examples

The secrets of successful importing are:

1) Practice with export first!  So that you learn the switches, and obtain the precise spelling of LDAP fields, for example sAMAccountName is correct, sAMAaccountNames has two mistakes and would cause the import to fail.

2) Create a good .CSV file.  Master the LDAP fields in the first row.

3) Use VBScript to enable accounts and set the password.  This overcomes the main limitation of CSVDE namely that you cannot import passwords, nor can you alter accounts in anyway.  See here for a VBScript to reset passwords.

Mastering bulk import will save you time when you need to create hundreds of user accounts.  CSVDE would be the method of choice if you have the users in a spreadsheet.

Example 1: Importing data with -i -f filename

To import a file into Active Directory use the CSVDE -i  which tells it to import.  -f users.csv  is the filename.  So the complete command is CSVDE -i -f users.csv  Note the space between the command and each switch.  The first line, referred to as the header, should have a list of the field names. For example, DN, FirstName, Surname.

Preparation: Open the text file with the users, and add LDAP attributes to the top row.

Command: CSVDE -i -f usersi.csv

Example 2: Using the -k to force an import

Command: CSVDE -i -k -f usersi.csv

Example 3: A CSV file with the LDAP attributes in the top row.

Preparation: If you wish to use this example below, firstly copy and paste it into notepad.  Then change the attributes to match your circumstances.  For example, change WonderDom to your domain name, and change the OU=Worcester to OU=yourOU.

 

I suggest importing the file into Excel, making your changes, then exporting it as a .CSV file.

 


dn,sAMAccountName,userPrincipalName,telephoneNumber,department,userAccountControl,objectClass
"CN=Peter Graham,OU=Worcester,DC=WonderDom",Peterg,Peterg@WonderDom.com,891-1239,Production,512,user
"CN=Janie Bourne,OU=Worcester,DC=WonderDom",Janieb,Janieb@WonderDom.com,891-1239,Production,512,user
"CN=Edgar Dunn,OU=Worcester,DC=WonderDom",Edgard,Edgard@WonderDom.com,891-1230,Production,512,user
"CN=Belinda Hart,OU=Worcester,DC=WonderDom",Belindah,Belindah@WonderDom.com,891-1231,Production,512,user
"CN=May Jamieson,OU=Worcester,DC=WonderDom",Mayj,Mayj@WonderDom.com,891-1232,Production,512,user
"CN=Leroy Ota,OU=Worcester,DC=WonderDom",Leroyo,Leroyo@WonderDom.com,891-1233,Production,512,user

 

Command CSVDE -i -k -f user3.csv

Troubleshooting

  • Check that you understand LDAP attributes and syntax: DC=domain, DC=COM.

  • Make sure that Excel is not open at the .csv you are trying to create.

  • Take care with your Find and Replace.

  • Check out the Error Messages.

  • Use the log switch: -j C:\

  • Experiment with different syntax. Try a different output filename.

  • Contact Guy Thomas - see email address below.

 

Try another bulk import

 

See more detailed examples in your eBook

 *


Google

WebComputerperformance.co.uk

GFi Events Manager

Guy Recommends: GFi EventsManager

Here is a solution to monitor, manage and archive thousands of events that are generated by devices across your entire network.  Get your free evaluation copy of GFI EventsManager.

 

Home Copyright © 1999-2008 Computer Performance LTD All rights reserved

Please report a broken link, or an error.

 


Download your eBook:  How to use CSVDE commands - only $6.25

CSVDESave hours of frustration and buy Guy's eBook.  The extra features include: detailed instructions on how to import and export user accounts, ten new pages of worked CSVDE examples.

You get a printer friendly version with copy enabled, and no expiry date.