Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


AD -List members from Global Group and nested group

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,41569
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> AD -List members from Global Group and nested group
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 AD -List members from Global Group and nested group - 1/2/2007 1:26:41 AM   
  A.Bedeker


Posts: 8
Score: 0
Joined: 12/21/2006
Status: offline
Hi,

I'm new with AD. I'm trying to get a list of members from a global group.
I've tried several scripts, but none was complete.

We have global groups as member aswell. I need a list of all members (incl. the members from the nested groups)

I also want to have the list in a *.txt file.

Example: I want all the members of globalgroup GGA_MUMM.
In this group there is an other group called GGF_1234.
I want a list of all the members of GGA_Mumm and GGF_1234 in a textfile.

Can someone help me!

Alex
 
 
Post #: 1
 
 RE: AD -List members from Global Group and nested group - 1/2/2007 1:52:26 AM   
  SAPIENScripter


Posts: 276
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
You need to take your script for enumerating groups and check the class of each member.  If the class is group, then call your group enumeration subroutine or function again.

_____________________________

Jeffery Hicks
Windows PowerShell MVP
SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com

Follow Me: http://www.twitter.com/JeffHicks

(in reply to A.Bedeker)
 
 
Post #: 2
 
 RE: AD -List members from Global Group and nested group - 1/2/2007 2:14:01 AM   
  A.Bedeker


Posts: 8
Score: 0
Joined: 12/21/2006
Status: offline
Do you have an example-script?

I'm not that good with the scripting stuff...

(in reply to SAPIENScripter)
 
 
Post #: 3
 
 RE: AD -List members from Global Group and nested group - 1/2/2007 2:25:30 AM   
  dm_4ever


Posts: 2722
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
quote:

 
A.Bedeker - I've tried several scripts, but none was complete.


Why don't you post what you have tried or currently have?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to A.Bedeker)
 
 
Post #: 4
 
 RE: AD -List members from Global Group and nested group - 1/2/2007 2:28:32 AM   
  A.Bedeker


Posts: 8
Score: 0
Joined: 12/21/2006
Status: offline
Didn't saved the scripts...because they did'n't work...

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: AD -List members from Global Group and nested group - 1/2/2007 2:53:21 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
Then perhaps you should find those non-working scripts again. Then post one that comes the closest to doing what you want along with a desription of what it does wrong or doesn't do right.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to A.Bedeker)
 
 
Post #: 6
 
 RE: AD -List members from Global Group and nested group - 1/2/2007 11:00:07 PM   
  A.Bedeker


Posts: 8
Score: 0
Joined: 12/21/2006
Status: offline
I found a script wich places all the members in a textfile. Now I need the nested members as well:

On Error Resume Next
gga= inputbox("Which global group?")
gga = "CN="&gga
Set objShell = Wscript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOU = GetObject("LDAP://OU=Application Management Groups,OU=Security Groups,DC=AD,DC=Intra") 'input the full  LDAP  path to your group's  OU here
objDesktop = objShell.SpecialFolders("Desktop")
For Each Group In objOU
If InStr(Group.Name, gga) Then 'input the name of the AD group to query here
Set objFile = objFSO.CreateTextFile(objDesktop & "\AD\Members of " & Group.Name & ".txt", 2)
objFile.WriteLine Group.Name
objFile.WriteLine "======================="
objFile.WriteLine

Set objGroup = GetObject _
("LDAP://" & Group.Name & ",OU=Application Management Groups,OU=Security Groups,DC=AD,DC=Intra")  'input the full  LDAP  path to your group's  OU here
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")
For Each strMember In arrMemberOf
Set objUser = GetObject("LDAP://" & strMember)
objFile.WriteLine objUser.samaccountname 
Next
objFile.Close
End If
Next
MsgBox "Completed script.",64,"Informational"

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: AD -List members from Global Group and nested group - 1/3/2007 9:11:22 PM   
  A.Bedeker


Posts: 8
Score: 0
Joined: 12/21/2006
Status: offline
Finaly got my script working.

For those who are interested:

On Error Resume Next
Dim UserCount, gga, CNgga
gga= inputbox("Which global group?")  'Get the requested Global Group
CNgga = "CN="&gga    'Change the group to a CN request
Set objShell = Wscript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOU = GetObject("LDAP://OU=Application Management Groups,OU=Security Groups,DC=AD,DC=Intra")  'input the full LDAP path to your group's OU here
objDesktop = objShell.SpecialFolders("Desktop") 'Folder for the output file
For Each Group In objOU
If InStr(Group.Name, CNgga) Then   'input the name of the AD group to query here
Set objFile = objFSO.CreateTextFile(objDesktop & "\AD\Members of " & Group.Name & ".txt", 2)  'Create the file
set UserCount = 0
objFile.WriteLine Group.Name
objFile.WriteLine "=================================="

Set objGroup = GetObject ("LDAP://" & Group.Name & ",OU=Application Management Groups,OU=Security Groups,DC=AD,DC=Intra")  'input the full LDAP path to your group's OU here
objGroup.GetInfo
arrMemberOf = objGroup.GetEx("member")
For Each strMember In arrMemberOf
Set objUser = GetObject("LDAP://" & strMember)
Select Case objUser.class 
  Case "user"
 objFile.WriteLine "     " & objUser.samaccountname  &" - " & objUser.Class
UserCount = UserCount + 1
  Case "group"
 'objFile.WriteLine objUser.samaccountname  &" - " & objUser.Class  &" - " & objUser.distinguishedName 
 enumGroupMembers(objUser.distinguishedName)
End Select
Next
objFile.WriteLine "Aantal gebruikers: " & UserCount 'Gives a total count of all the users.
objFile.Close
End If
Next
MsgBox "Completed script.",64,"Informational"
Sub enumGroupMembers(sObjDN)
Dim oContainer, obj, sDN 
 Set oContainer=GetObject ("LDAP://" & sObjDN)   

For each obj in oContainer.members
 Select Case LCase(obj.Class)   
 Case "user" , "contact"
  objFile.WriteLine "     " & obj.sAMAccountName  &" - " & obj.Class 
  UserCount = UserCount + 1
 Case "group"
  'objFile.WriteLine obj.sAMAccountName  &" - " & obj.Class  &" - " & objUser.distinguishedName
  EnumGroupMembers obj.distinguishedName
End Select   
Next
End Sub

(in reply to A.Bedeker)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> AD -List members from Global Group and nested group Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts