troubleshooting Question

VB Script problem

Avatar of bsharath
bsharathFlag for India asked on
Microsoft Legacy OSMicrosoft Server OS
22 Comments1 Solution1318 ViewsLast Modified:

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
' 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
      intCounter = intcounter +1
   End If
WScript.Echo strGroup & " has " & intCounter & " new members"


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)

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


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 22 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros