I am trying to automate my callcenter user builds. We have 2 or 3 classes a week of 15 - 20 agents. I read from an excel file (Thanks Kynder
) the user ID, full name, description , password, logon script and dept. (which I'll use to assign groups if I can get this working) I get the user account built ok, but none of the other values for name, description etc are working. If the user ID is 9999 I'll get an account 9999 with full name as 9999 and no other info... I have checked my values using ? $value1 ? and all come out ok!
Help!
code:
Break ON
CLS
$Class = "C:\training\current_build.xls"
ReadData($Class)
? "ID's Have Been Successfully Created"
Function ReadData($Class)
$object = CreateObject("Excel.Application")
If $Class = ""
? "Class File not found"
? "The Excel File "+$Class+" Must exist before ID Build is run"
Goto Clear
EndIf
; Open Workbook
$_=$object.workbooks.Open ($Class)
$Cell = 2 ;Set start value, Row one and two are column and group Headings
$x = $object.cells($Cell, 1).value
While $object.cells($Cell, 1).value <> ""
$Cell = $Cell + 1
If $object.cells($Cell, 1).value = ""
Goto Clear
EndIf
$value1 = $object.cells($Cell, 1).value
$value2 = $object.cells($Cell, 2).value
$value3 = $object.cells($Cell, 3).value
$value4 = $object.cells($Cell, 4).value
$value5 = $object.cells($Cell, 5).value
CreateUser ($Value1, "CCC")
Loop
:clear
$object.application.Quit
$object = ""
EndFunction
Function CreateUser ($XName, $XDomain)
? "Creating Account..."
$UserName = $Value1
$DomainName = "CCC"
;Create the objects Domain and User.
$Domain = GetObject("WinNT://" + $DomainName + ",domain")
$User = $Domain.Create("user", $UserName)
;Set user account flags.
$User.FullName = $Value2
$User.Description = $Value3
$User.SetPassword = $Value4
$User.LoginScript = "logon.bat"
$User.Put ("PasswordExpired", 1)
$User.SetInfo
;Cleanup Objects Domain and User
Set $User = 0
Set $Domain = 0
Set $UserName = 0
Set $DomainName = 0
? "ID complete"
EndFunction