Obs1.: O Microsoft Office deve estar instalado no servidor
Osb2.: Deve executar com a conta 'administrador' (administrator versão inglês)
1) Primeiramene, faça o download da planilha com o exemplo de formado a ser usado;
Osb2.: Deve executar com a conta 'administrador' (administrator versão inglês)
1) Primeiramene, faça o download da planilha com o exemplo de formado a ser usado;
2) Salve-a no C:\ do seu servidor e altere de acordo com sua necessidade (Deixe o nome do arquivo como está);
3) Copie e cole o script abaixo para um arquivo .txt
' UserSpreadsheet .vbs' Sample VBScript to create User accounts from a spreadsheet' Author Guy Thomas http://computerperformance.co.uk/' Version 4.6 - June 2005' ------------------------------------------------------'Option ExplicitDim objRootLDAP, objContainer, objUser, objShellDim objExcel, objSpread, intRowDim strUser, strOU, strSheetDim strCN, strSam, strFirst, strLast, strPWD
' -------------------------------------------------------------'' Important change OU= and strSheet to reflect your domain' -------------------------------------------------------------'
strOU = "OU=Temp ," ' Note the commastrSheet = "c:\UserSpread1.xls"
' Bind to Active Directory, Users container.Set objRootLDAP = GetObject("LDAP://rootDSE")Set objContainer = GetObject("LDAP://" & strOU & _objRootLDAP.Get("defaultNamingContext"))
' Open the Excel spreadsheetSet 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 strSheetDo 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, 3).Value)strLast = Trim(objExcel.Cells(intRow, 4).Value)strPWD = Trim(objExcel.Cells(intRow, 5).Value)
' Build the actual User from data in strSheet.Set objUser = objContainer.Create("User", "cn=" & strCN)objUser.sAMAccountName = strSamobjUser.givenName = strFirstobjUser.sn = strLastobjUser.SetInfo
' Separate section to enable account with its passwordobjUser.userAccountControl = 512objUser.pwdLastSet = 0objUser.SetPassword strPWDobjUser.SetInfo
'On Error GoTo TrataErroOn Error Resume Next
intRow = intRow + 1LoopobjExcel.Quit
WScript.Quit
4) Altere a OU de destino para onde o Script vai salvar os novos usuários (No script);
5) Feche o .txt, salve com o nome 'UserSpreadsheet.vbs';
6) Execute e veja o resultado!
erro Linha 21 Caract 1
ResponderExcluirNão ha tal objeto no servidor
codigo 80072030
origem null
Jonathan, Criou a OU TEMP?
ResponderExcluirA planilha está no C:\ do servidor?
O office está instalado no servidor?
o script deve ser executado com adm. aqui deu certo.
E seu eu quiser criar um grupo dentro de uma "Sub OU", tem como? Por exemplo: Alunos > 2012 > 5osAnos.
ResponderExcluir