Компьютеры «член » Скрипта 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 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 Settings257466DesktopCreate Computer AccountsComputer Accounts.xls" 

' Bind to Active Directory, Computers container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" amp; strOU amp; _
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=" amp;   strComputer)
   objComputer.Put "sAMAccountName", strComputer amp; "$"
   objComputer.Put "userAccountControl", 4096
   objComputer.SetInfo 
   intRow = intRow   1
Loop
objExcel.Quit 

WScript.Quit
  

Комментарии:

1. Помогает ли эта ветка форума ?

Ответ №1:

Благодаря комментарию от oracle certified professional я смог придумать следующее, чтобы добавить созданные компьютеры в группу.

 ' 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://" amp; strGroup)
objGroup.add objComputer.adspath
  

Просто поместите вышеуказанные строки между objComputer.SetInfo и intRow = intRow 1, и это добавит компьютер в группу.