i have a script that runs weekly and basically compares an external User-Account-database to my ActiveDirectory.
Changes can be made on both sides, so i have to check in each direction.
But, at the current state, i do that quite "bute force", i think.
And this is what i do:
At first i get an export-txt-file of the external User-DB with all accountnames and a few important details
(e.g. email) seperated with "#"-letters.
Then, i export the related AD-group, also to a text file.
Now i read every line in the first *.txt and search for it in the second file.
If not found i create a delta-file containing the changes to make.
After that i do the same with the second file compared to the first.
At the moment i've got 3000 useraccounts so the script takes 10 to 15 min to
run. Thats not nice but acceptable.But in the near future i will have approx
15000 - 20000 Accounts to compare and the runtime will be too long.
Apart from that i open the second file 3000 times and read every line... ugly scripting i think...
I've got a fast server with enough memory for the task, so i was thinking about reading the files into memory
and do the checking there, but i dont know how.
a piece of the script for better understanding (i hope):
;... Compare 1of4: RD-Database -> AD
$rc = Open (1,"$datapath\$externalDBfile",2)
$lineA1 = ReadLine (1)
If $lineA1 <> ""
$arrayA1 = Split ($lineA1,"#",4)
$loginA1 = $arrayA1
$rc = Open (5,"$datapath\$ADexpAll",2)
$lineB1 = ReadLine (5)
If $lineB1 <> ""
$arrayB1 = Split ($lineB1,"#",2)
$loginB1 = $arrayB1
If $loginB1 = $loginA1 $rc = Close (5) Goto A1next EndIf
$rc = Close (5)
; User not found
$wlineA1 = $arrayA1+"#"+$arrayA1+"#"+$arrayA1+"#$Remarks#Create_User@crlf"
$rc = WriteLine (4,$wlineA1)
$deltaA1 = $deltaA1 + 1
[Edited by NTDOC to remove long lines.]