DAckroyd Posted February 3, 2009 Posted February 3, 2009 Does anyone know if you can create a bulk load of users in Active Directory by either using CSV (or similar) or if their is a power tools script that will do the job (and if so how to use it?) Thanks, Dave
jamesb Posted February 3, 2009 Posted February 3, 2009 Quite easily yes, the scripting guys at Microsoft explain this. I'll put up a URL in a sec. Edit: http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct08/hey1020.mspx There you go. Gives some sample code and takes you through step by step how it works. 1
ChrisP Posted February 3, 2009 Posted February 3, 2009 Here is what i use for adding from an excel file. It may be of some use, not much needs changing... Four columns used in the excel sheet are: username,password,lastname,firstname Dim objRootLDAP, objContainer, objUser, objShell Dim objExcel, objSpread, intRow, strUser, strOU, strSheet Dim strCN, strSam, strFirst, strLast, strPWD HomeServer = "datastore2" strGroup = "students" strOU = "OU=EHS," ' Note the comma strSheet = "Z:\!!-Scripts\2009\newusr\src.xls" Set objRootLDAP = GetObject("LDAP://rootDSE") Set objContainer = GetObject("LDAP://" & strOU & objRootLDAP.Get("defaultNamingContext")) strDNSDomain = objRootLDAP.Get("DefaultNamingContext") Set objExcel = CreateObject("Excel.Application") Set objSpread = objExcel.Workbooks.Open(strSheet) intRow = 1 'Row 1 often contains headings Do Until objExcel.Cells(intRow,1).Value = "" strSam = Trim(objExcel.Cells(intRow, 1).Value) strPWD = Trim(objExcel.Cells(intRow, 2).Value) strLast = Trim(objExcel.Cells(intRow, 3).Value) strFirst = Trim(objExcel.Cells(intRow, 4).Value) strCN = strFirst & " " & strLast Set objUser = objContainer.Create("User", "cn=" & strCN) objUser.sAMAccountName = strSam objUser.displayName = strCN objUser.description = strSam objUser.givenName = strFirst objUser.sn = strLast objUser.HomeDrive = "Z:" objUser.HomeDirectory = "\\"&HomeServer&"\"&strSam&"$" objUser.SetInfo objUser.userAccountControl = 512 ' objUser.pwdLastSet = 0 objUser.SetPassword strPWD objUser.SetInfo intRow = intRow + 1 Set objGroup = GetObject("LDAP://cn="&strGroup&",cn=users,"&strDNSDomain) objGroup.Add objUser.AdsPath 1
PiqueABoo Posted February 3, 2009 Posted February 3, 2009 Haven't used it, but it's in system32 on 2K8 so.... ..err... no... you can use it on 2K8.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now