Jump to content


Import CSV file to Add users in AD

  • Please log in to reply
2 replies to this topic

#1 jslegers



  • Active Members
  • Pip
  • 58 posts

Posted 25 August 2010 - 01:29 PM


I want to create a script that can read a csv file and use this data to create users in Active Directory with the tool dsadd.

CSV file looks like this :

ABeerens;Ans Beerens;Ans;Beerens;Welkom01
ABos;Annemiek Bos;Annemiek;Bos;Welkom01
ABraat;Ans Braat;Ans;Braat;Welkom01

Is it possible to create variables from the different pieces in the file.
For example

$Var2=Ans Beerens

dsadd $Var1,Var2 ....


And so on.

I want to create a loop until the end of the file is reached.

#2 kaotkbliss



  • Active Members
  • PipPipPipPipPipPip
  • 2,529 posts

Posted 25 August 2010 - 02:00 PM

You could read the file to an array (_FileReadToArray)
then loop through that array, splitting each record into smaller arrays with StringSplit

In your example, you would have an array set up like

;1=ABeerens;Ans Beerens;Ans;Beerens;Welkom01
;2=ABos;Annemiek Bos;Annemiek;Bos;Welkom01
;3=ABraat;Ans Braat;Ans;Braat;Welkom01
For $i=1 to Ubound($csv)-1
;2=Ans Beerens
;Then you can dsadd $csv[1], $csv[2]



My first project  Allin1 Program launcher

Bill Calculator

Got <Insert problem here>? There's an AutoIt script for that!

#3 water



  • MVPs
  • 16,624 posts

Posted 26 August 2010 - 03:26 PM

May I suggest to use the Active Directory UDF - function _AD_CreateUser - to add users? You can create a user in a different OU in one go and have better error handling.
You can find the download link in my signature below.

Edited by water, 26 August 2010 - 03:27 PM.

Active Directory (2014-07-21 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
ADO - Wiki

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users