SRnd(@MSECS)
SetOption("CaseSensitivity","ON")
Dim $Accounts[2,0]
$Count = 0
Open(1,"Users.txt")
$Line = ReadLine(1)
While @ERROR = 0
ReDim Preserve $Accounts[2,$Count]
$Accounts[0,$Count] = Split($Line,",")[0] ; Full Name
$Accounts[1,$Count] = Split($Line,",")[1] ; SAMAccountName
$Accounts[2,$Count] = MakePass() ;Generated Password
$Count = $Count +1
$Line = ReadLine(1)
Loop
Close (1)
Open (1,"users_Wpass.txt",5)
For $Element = 0 to ($Count -1)
WriteLine(1,$Accounts[0,$Element]+" "+$Accounts[1,$Element]+" "+$Accounts[2,$Element]+@CRLF)
$Domain = GetObject("LDAP://cn=Users,dc=us,dc=fabricom,dc=com")
$user = $Domain.Create("user", "cn=" + $Accounts[0,$Element])
$User.Put ("sAMAccountName", $Accounts[1,$Element])
$user.SetPassword ($Account[2,$Element])
$user.Description = "Voice Admin"
$user.SetInfo
$GroupObj = GetObject("LDAP://cn=Administrators,cn=Builtin,dc=us,dc=fabricom,dc=com")
$UserObj = GetObject("LDAP://cn="+$Accounts[0,$Element]+",cn=Users,dc=us,dc=fabricom,dc=com")
$GroupObj.add ($UserObj.ADsPath)
$GroupObj.SetInfo
$GroupObj = GetObject("LDAP://cn=Domain Admins,cn=Users,dc=us,dc=fabricom,dc=com")
$GroupObj.add ($UserObj.ADsPath)
$GroupObj.SetInfo
$userObj.pwdLastSet = -1
$userObj.AccountDisabled = 0
$userObj.SetPassword ($Account[2,$Element)
$userObj.setinfo
Next
Close(1)
Function MakePass()
$MakePass = ""
While Len($MakePass) < 8
$Value = Rnd(122)
If $Value >= 48 And $Value <= 57
$MakePass = $MakePass + Chr($Value)
EndIf
If $Value >= 65 And $Value <= 90
$MakePass = $MakePass + Chr($Value)
EndIf
If $Value >= 97 And $Value <= 122
$MakePass = $MakePass + Chr($Value)
EndIf
Loop
EndFunction