Vbscript 电脑“;成员;VBS脚本

Vbscript 电脑“;成员;VBS脚本,vbscript,Vbscript,我有下面的VBS脚本,它在为我工作的学校添加多个新的计算机帐户时非常有用。我想知道是否有人可以修改脚本,以便它也可以添加一个组到新创建的计算机帐户的“成员”选项卡。谢谢 ' Author Guy Thomas http://computerperformance.co.uk/ ' Found at http://www.computerperformance.co.uk/vbscript/vbscript_computer_spreadsheet.htm ' Version 1.2 - May

我有下面的VBS脚本,它在为我工作的学校添加多个新的计算机帐户时非常有用。我想知道是否有人可以修改脚本,以便它也可以添加一个组到新创建的计算机帐户的“成员”选项卡。谢谢

' Author Guy Thomas http://computerperformance.co.uk/
' Found at http://www.computerperformance.co.uk/vbscript/vbscript_computer_spreadsheet.htm
' Version 1.2 - May 2010
' ------------------------------------------------------' 
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=New Computers,OU=Workstations,OU=123,OU=Site Based Computer Accounts ," ' Note the comma
strSheet = "C:\Documents and Settings\257466\Desktop\Create Computer Accounts\Computer Accounts.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 containes headings

' Here is the loop that cycles through the cells
Do Until objExcel.Cells(intRow,1).Value = ""
   strComputer = objExcel.Cells(intRow, 1).Value

   ' Build the actual computer.
   Set objComputer = objContainer.Create("Computer", _
   "cn=" &   strComputer)
   objComputer.Put "sAMAccountName", strComputer & "$"
   objComputer.Put "userAccountControl", 4096
   objComputer.SetInfo 
   intRow = intRow + 1
Loop
objExcel.Quit 

WScript.Quit

多亏了oracle认证专家的评论,我能够想出以下方法将创建的计算机添加到组中

' Added section to add the computer to the group
' Comment out with if not needed
Dim objGroup, strGroup
strGroup = "OU=New Computers,OU=Workstations,OU=123,dc=company,dc=com"
Set objGroup = GetObject("LDAP://" & strGroup)
objGroup.add objComputer.adspath
只需将上面的行放在objComputer.SetInfo和intRow=intRow+1之间,它就会将计算机添加到一个组中。

有帮助吗?
' Added section to add the computer to the group
' Comment out with if not needed
Dim objGroup, strGroup
strGroup = "OU=New Computers,OU=Workstations,OU=123,dc=company,dc=com"
Set objGroup = GetObject("LDAP://" & strGroup)
objGroup.add objComputer.adspath