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("DefaultNa
mingContex
t")
' 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.ADsPa
th)
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
strGroup = "CN=Coal Porters," => is this correct for your situation? The group is assumed to be in the same OU as the users you want to add.