Problem to Export Group's member from active directory

Hi all :)
I've a VBscript that list all my group in a file and then i read that file to export the member of that Group.
when i execute it' it said that my variable are not a collection.

I pass all the day trying to figure out what the problem is :S

Thanks for your Help
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this, it's worked fine for me.
' GroupEnum.vbs
' VBScript to discover who is a member of the Administrators Group
' Author Guy Thomas
' Version 1.3 August 2005
' ----------------------------------------------------------' 
Option Explicit
Dim strMember, strDNSDomain, strContainer
Dim objGroup, objRootDSE
Dim arrMemberOf
'  Bind to Active Directory' 
strContainer = "cn=Administrators,cn=Builtin, "
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
'  Get the Builtin Administrators group
Set objGroup = GetObject ("LDAP://"& strContainer & strDNSDomain)
arrMemberOf = objGroup.GetEx("member")
' Loop = For Each .... Next 
' WScript.Echo "Members of Group " & strContainer
For Each strMember in arrMemberOf
   WScript.echo strMember
' End of Sample Group Enum Member Script

Open in new window

Hi, this is a script that I use to get the members of a specific group, which could easily take input of group names from a text file:

Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strUserDomain = wshNetwork.UserDomain
strUserComputer = wshNetwork.ComputerName
strUserName = wshNetwork.UserName

strGroup = InputBox("Please type the AD group name to get members of:", "Group Name", "mf_users")
Set objWinntObject = GetObject("WinNT://" & strUserDomain & "/" & strGroup)

strResults = "Results" & VbCrLf & "======="
strResults = strResults & VbCrLf & "Group: " & objWinntObject.Name
strMembers = GetMembers(GetObject("WinNT://" & strUserDomain & "/" & objWinntObject.Name))
strResults = strResults & VbCrLf & strMembers & VbCrLf

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile("DomainGroups.txt", True)
objOutputFile.Write strResults
Set objOutputFile = Nothing
Set objFSO = Nothing

MsgBox "Done.  Please see output text file."

Function GetMembers(objGroup)      
      strMembers = ""
      For Each objMember In objGroup.Members
            If strMembers = "" Then
                  strMembers = objMember.Name
                  strMembers = strMembers & VbCrLf & objMember.FullName
            End If
      GetMembers = strMembers
End Function


Jared LukerCommented:
If your just looking for group membership, then you could just use the showmbrs.exe utility from the server resource kit.  I use it all the time for a quick listing of a particular group.
Malli BoppeCommented:
below script give all the members of all groups in the domain.

Option Explicit

Dim objConnection, objCommand, objRecordSet, objGroup, objRootDSE,objFile, objFileSystem, objMember
Dim strLine

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.OpenTextFile("Groups.xls", 2, True, 0)
objFile.WriteLine "Group Name" & VbTab & "Number of Members" & VbTab & "Members"

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

Set objRootDSE = GetObject("LDAP://RootDSE")
objCommand.CommandText = "SELECT name, aDSPath,mail " &_
      "FROM 'LDAP://" & objRootDSE.Get("defaultNamingContext") & "' WHERE objectClass='group'"
Set objRootDSE = Nothing

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 600
objCommand.Properties("Cache Results") = False

Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
      Set objGroup = GetObject(objRecordSet.Fields("aDSPath"))
            strLine = objRecordSet.Fields("name") & VbTab
            strLine = strLine & objGroup.Members.Count & VbTab

            For Each objMember in objGroup.Members
                  strLine = strLine & objMember.Get("name") & ","

            If Right(strLine, 1) = "," Then
                  strLine = Left(strLine, Len(strLine) - 1)
            End If
            objFile.WriteLine strLine
      Set objGroup = Nothing

Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing

Set objFile = Nothing
Set objFileSystem = Nothing

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
morijonaAuthor Commented:
Thanks alot :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.