Question : VB Script problem

Hi,

This script has to add a a group to all users in the OU.

' GroupAddLots.vbs
' Free example VBScript to add users to a group.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.3 - May 2005
' ---------------------------------------------------------------'
Option Explicit
Dim objRootLDAP, objGroup, objUser, objOU
Dim strOU, strGroup, strDNSDomain
Dim intCounter

' Check these objects referenced by strOU, strGroup exist in strOU
strOU = "OU=Newport,"
strGroup = "CN=Coal Porters,"

' Bind to Active Directory and get LDAP name
Set objRootLDAP = GetObject("LDAP://RootDSE")
strDNSDomain = objRootLDAP.Get("DefaultNamingContext")

' Prepare the OU and the Group
Set objGroup = GetObject("LDAP://"& strGroup _
& strOU & strDNSDomain)
Set objOU =GetObject("LDAP://" & strOU & strDNSDomain)

' On Error Resume next
intCounter = 1
For Each objUser In objOU
   If objUser.Class = lcase("User") then
      objGroup.add(objUser.ADsPath)
      intCounter = intcounter +1
   End If
Next
WScript.Echo strGroup & " has " & intCounter & " new members"

Wscript.Quit

End of Add lots of members to group VBScript


I get this error.

---------------------------
Windows Script Host
---------------------------
Script:      C:\Add lots of users to a group.vbs
Line:      22
Char:      1
Error:      There is no such object on the server.
Code:      80072030
Source:       (null)

---------------------------
OK  
---------------------------
can anyone help me.Can you modify this if possible to take the names ffrom the file instead of the OU.

REgards
Sharath

Answer : VB Script problem

Ok:
1. Download a bug-free version of the script here: http://the-roberts-family.net/vbscript/autg.zip

2. Run the command line:
cscript.exe autg.vbs  group_name  user_file_path  log_file_path
This will display information, if the usernames are valid, like:

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Validating names in user file.
  2 lines processed. 0 error(s).
(No log file written).
Use /di switch to actually add users to group.

3. If no errors, run the script again with the /di option:
cscript.exe autg.vbs  group_name  user_file_path  log_file_path /di
4. verify the logfile
Random Solutions  
 
programming4us programming4us