I have a .csv which contains around 1000 names for user account creation.
Column A is username Column B is first name Column C is Surname.

I have been trying to use the following UDF with this .csv to create the accounts but with no luck.

 Code:
CreateUserAccount("domain",
                  "cn=users",
                  "cr.test",
                  "Cr",
                  "R",
                  "Test",)

Function CreateUserAccount($Domain,
                           $ContainerDN,
                           $Account,
                           optional $FirstName,
                           optional $MiddleInitial,
                           optional $LastName,
                           optional $Description,
                           optional $Office,
                           optional $Telephone,
                           optional $Email,
                           optional $WebPage,
                           optional $userPrincipalName )


Dim $aDom, $part, $sDNdom, $LDAPpath, $oContainer, $oUser

    if VarTypeName($userPrincipalName) = "Empty"
        $userPrincipalName = $Account + "@@" + $Domain
    endif

    $aDom = split($Domain,".")
    for each $part in $aDom
        $sDNdom = "" + $sDNdom + ",dc=" + $part
    next

    $LDAPpath = "LDAP://" + $Domain + "/" + $ContainerDN + $sDNdom
    ;? $LDAPpath

    $oContainer = GetObject($LDAPpath)
    if @error
        ? "GetObject Error: " + @error +  " "  + @Serror
    endif

    $oUser = $oContainer.Create("User", "cn=" + $Account)
    if @error
        ? "Create Error: " + @error +  " "  + @Serror
    endif

    $oUser.Put("sAMAccountName", $Account)
    $oUser.Put("givenName", $FirstName)     ;First Name
    $oUser.Put("Initials", $MiddleInitial)  ;Initials
    $oUser.Put("sn", $LastName)             ;Last Name(Surname)
    $oUser.Put("displayName",$LastName  + iif($LastName, ", ","") +
                             $FirstName + iif($MiddleInitial, " ", "") +
                             $MiddleInitial) ;Display name
    $oUser.Put("description", $Description) ;Description
    $oUser.Put("physicalDeliveryOfficeName",$Office) ;Office
    $oUser.Put("telephoneNumber",$Telephone);Telephone
    $oUser.Put("mail",$Email)               ;E-mail
    $oUser.Put("wWWHomePage",$WebPage)      ;Web page
    $oUser.Put("userPrincipalName", $userPrincipalName) ;userPrincipalName

    $oUser.SetInfo
    $CreateUserAccount = @error
    if $CreateUserAccount
        ? "SetInfo Error: " + @error +  " "  + @Serror
    endif
Endfunction
 


Whilst I just about understand how to create and use a simply array I dont understand how to create an array within an array. i.e. how to script it so that it always looks for the first name in column B and the surname in column c. I have been trying to use a bit of the above udf and a bit of readexcel2.udf but have only achieved confusion!

Can someone shed some light on this for me please?
Thanks