kaaaa
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Sk1f вот нарыл такой скрипт: Option Explicit Dim objRootLDAP, objContainer, objUser, objShell Dim objExcel, objSpread, intRow Dim strUser, strOU, strSheet Dim strCN, strSam, strFirst, strLast, strPWD, strdisplay, strdesc, strprinc, strinit ' -------------------------------------------------------------' ' Important change OU= and strSheet to reflect your domain ' -------------------------------------------------------------' strOU = "OU=Accounts ," ' Note the comma strSheet = "d:\scripts\UserSpread1.xls" ' Bind to Active Directory, Users container. Set objRootLDAP = GetObject("LDAP://rootDSE") Set objContainer = GetObject("LDAP://" & strOU & _ objRootLDAP.Get("defaultNamingContext")) ' Open the Excel spreadsheet Set objExcel = CreateObject("Excel.Application") Set objSpread = objExcel.Workbooks.Open(strSheet) intRow = 3 'Row 1 often contains headings ' Here is the 'DO...Loop' that cycles through the cells ' Note intRow, x must correspond to the column in strSheet Do Until objExcel.Cells(intRow,1).Value = "" strSam = Trim(objExcel.Cells(intRow, 1).Value) strCN = Trim(objExcel.Cells(intRow, 2).Value) strFirst = Trim(objExcel.Cells(intRow, 4).Value) strLast = Trim(objExcel.Cells(intRow, 3).Value) strPWD = Trim(objExcel.Cells(intRow, 5).Value) strdisplay = Trim(objExcel.Cells(intRow, 6).Value) strdesc = Trim(objExcel.Cells(intRow, 7).Value) strprinc = Trim(objExcel.Cells(intRow, 8).Value) strinit = Trim(objExcel.Cells(intRow, 9).Value) ' Build the actual User from data in strSheet. Set objUser = objContainer.Create("User", "cn=" & strCN) objUser.sAMAccountName = strSam objUser.givenName = strFirst objUser.sn = strLast objUser.displayName = strdisplay objUser.description = strdesc objUser.userPrincipalName = strprinc objUser.initials = strinit objUser.SetInfo ' Separate section to enable account with its password objUser.userAccountControl = 512 objUser.pwdLastSet = 0 objUser.SetPassword strPWD objUser.SetInfo intRow = intRow + 1 Loop objExcel.Quit WScript.Quit щас попробую |