Import CSV file to Add users in AD
#1
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
$Var1=ABeerens
$Var2=Ans Beerens
$Var3=Ans
$Var4=Beerens
$Var5=Welkom01
dsadd $Var1,Var2 ....
Loop
And so on.
I want to create a loop until the end of the file is reached.
#2
Posted 25 August 2010 - 02:00 PM
then loop through that array, splitting each record into smaller arrays with StringSplit
In your example, you would have an array set up like
_FileReadToArray("Whatever\file.csv",$csv)
;0=3
;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
$record=StringSplit($csv[$i],";")
;0=5
;1=ABeerens
;2=Ans Beerens
;3=Ans
;4=Beerens
;5=Welkom01
;Then you can dsadd $csv[1], $csv[2]
Next
010101000110100001101001011100110010000001101001011100110010000
001101101011110010010000001110011011010010110011100100001
My first project Allin1 Program launcher
Got <Insert problem here>? There's an AutoIt script for that!
#3
Posted 26 August 2010 - 03:26 PM
You can find the download link in my signature below.
Edited by water, 26 August 2010 - 03:27 PM.
UDFs:
Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts
WordEX (2012-12-29 - Version 1.3 released) - Download
ExcelEX (2013-05-11 - Alpha 4 released) - Download
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users



