Hello,

This is what I want:

1. Move users from multiple organizational units to one (Old Student) and disable them.
2. Check if users from Old Student are in the CSV, if so move them to the OU specified in the CSV.
3. Add all the other users from the CSV that where not in the OU Old Student.

This way all the students that where in the AD but not in the CSV will be in one OU and disabled.

I allready have step 3 and i have a script that lets me put all the user attributes in to arrays.

 Code:
Break on
If InGroup ("Users,dc=Testserver,dc=local",
		Move "ou=Oud Leerling,dc=Testserver,dc=local")

$filename = "test1.csv"

If Open(1,$filename) = 0

 $line = ReadLine(1)

 While @ERROR = 0

  $array = Split($line,",")

 ?
? "De volgende gebruiker wordt toegevoegd:"
? $array[0] + " uit lokaal " + $array[4] + "."
CreateUserAccount("ou="+$array[4]+",dc=TestServer,dc=local",
                  $array[3],
		      $array[3],
                  $array[1],
                  $array[2],
                  $array[0],
                  $array[3],
                  $array[4],
			$array[4])
			
			Function CreateUserAccount($dc,
							   $sAMAccountName,
							   $UserName,
							   $FirstName,
							   $LastName,
							   $DisplayName, 
							   $Passwd,
							   $Group,
							   $Resident )

;-------------- Create User Account ------------------------------------

$adsOU = GetObject("LDAP://" + $dc)

If @ERROR<>0
	? "ERROR: Cannot access OU"
	;? $dc
	? @SERROR + " (" + @ERROR + ")"
	Quit 1
EndIf

$adsUser = $adsOU.Create("user", "cn=" + $UserName)
$adsUser.put("sAMAccountName", $sAMAccountName)
$adsUser.Put("DisplayName", $DisplayName)
$adsUser.Put("ProfilePath", "\\Server\Profiles\" + $Group + "\" + $UserName)
$adsUser.SetInfo

$adsUser = GetObject("LDAP://cn=" + $UserName + "," + $dc)

$adsUser.GetInfo
$adsUser.SetPassword($Passwd)
$adsUser.AccountDisabled = 0
$adsUser.IsAccountLocked = 0
$adsUser.SetInfo

EndFunction
  

  $line = ReadLine(1)
  
 Loop

 $= Close(1)