Hi,
I found the below vbscript from
http://computerperformance.co.uk/vbscript/vbscript_computer_spreadsheet.htm
which allows me to add computer accounts into Active Directory from a
spreadsheet. That part works great. What I'd like to know is how to ammend
this script so it allows a specified Group to join these computers to the
domain.
Any help would be much appreciated.
' ComputerSpreadsheetADV.vbs
' Sample VBScript to Create Computer Accounts from a Spreadsheet
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.4 - May 2005
' ------------------------------------------------------'
Option Explicit
Dim strComputer, strOU, strSheet, intRow
Dim objRootLDAP, objContainer, objComputer, objShell
Dim objExcel, objSpread
' -------------------------------------------------------------'
' Important change OU= and strSheet to reflect your domain
' -------------------------------------------------------------'
strOU = "OU=newComputers ," ' Note the comma
strSheet = "C:\newComputers.xls"
' Bind to Active Directory, Computers 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 = 2 'Row 1 often contains headings
' Here is the loop to cycle through the cells
Do Until objExcel.Cells(intRow,1).Value = ""
strComputer = objExcel.Cells(intRow, 1).Value
' Build the actual computer and add error-correcting code
On Error Resume next
Set objComputer = objContainer.Create("Computer", _
"cn=" & strComputer)
objComputer.Put "sAMAccountName", strComputer & "$"
objComputer.Put "userAccountControl", 4096
objComputer.SetInfo
If err.number <> vbEmpty Then
Wscript.Echo "Error " & err.number
End If
intRow = intRow + 1
Loop
objExcel.Quit
' Optional section to launch Active Directory Uses and Computers
Set objShell=CreateObject("WScript.Shell")
objShell.Run "%systemroot%\system32\dsa.msc"
WScript.Quit
' End of Sample ComputerSpreadsheetADV VBScript.
--
Please reply to news group only. Thank you.