?
Solved

list members in distribution group

Posted on 2011-09-21
9
Medium Priority
?
541 Views
Last Modified: 2012-05-12
Hello,

I need to print out members of a distribution group.   However, within this distribution group, it has a lot of other distribution groups.  

Is it possible to just print out all the members?

We have Win2k3 and Exchange 2k3.  

Please advise.

Thanks.
0
Comment
Question by:nav2567
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 4

Expert Comment

by:ctc1900
ID: 36576905
0
 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
ID: 36578814
I would suggest you to try powershell with Quest.

Install powershell. Install Quest CMDlets for Active directory from http://www.quest.com/powershell/activeroles-server.aspx.

Get-QADGroupMember -Indirect "GROUPNAME"

You can export the list directly to a CSV if required.
Get-QADGroupMember -Indirect "GROUPNAME" |export-csv DLmembers.csv

Let me know if you require any help on this.

Cheers,
Shaba
0
 

Author Comment

by:nav2567
ID: 36584585
Thanks.  We actually have a mixed environment with 2008 DCs on the network.  But a WIN2K3 server actually still hold the FISO.  

Or another question is, can I just use any 2008 domain member server, open up a command prompt, type powershell, and type the Get-QADGroupMember -Indirect "GROUPNAME" command?

Please advise again.  Thanks.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 23

Expert Comment

by:yo_bee
ID: 36584613
Here is a script that I used in the past


' *****************************
' * List All Groups in the Domain and
' * List All Members of each Group
' * 
' * Output to a text file on the user's desktop in the format:
' * group name <tab> type <tab> member name <tab> type
' * Prompt for text file name.
' * Written by James Anderson, July 2009
' *****************************
' Variables
Const MY_DOMAIN = "<DC=<name>,DC=<local>"
' *****************************
' Start Main
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_LOCAL_GROUP = &h4
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Const MYPROMPT = "Enter the Output filename (i.e. Groups.txt) that will be saved on your desktop:"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Setup the output file
If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
  WScript.StdOut.Write MYPROMPT & " "
  strMyFileName = WScript.StdIn.ReadLine
Else
  strMyFileName = InputBox( MYPROMPT )
End If
if strMyFileName = "" then
  wscript.quit
end if
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
strMyFileName = "c:\" & strMyFileName 'WshSysEnv("USERPROFILE") & "\Desktop\" & strMyFileName
Set WshSysEnv = nothing
Set WshShell = nothing
if objFSO.FileExists(strMyFileName) then
  'objFSO.DeleteFile(strMyFileName)
  wscript.echo "That filename already exists"
  wscript.quit
end if

' Get a recordset of groups in AD
Set objMyOutput = objFSO.OpenTextFile(strMyFileName, ForWriting, True)
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
objCommand.CommandText = _
    "SELECT ADsPath, Name FROM 'LDAP://" & MY_DOMAIN & "' WHERE objectCategory='group'" 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

' For each Group, Get group properties
Do Until objRecordSet.EOF
  Set objGroup = GetObject(objRecordSet.Fields("ADsPath").Value)
  strGroupName = objRecordSet.Fields("Name").Value
  If objGroup.GroupType AND ADS_GROUP_TYPE_LOCAL_GROUP Then
    strGroupDesc = "Domain local "
  ElseIf objGroup.GroupType AND ADS_GROUP_TYPE_GLOBAL_GROUP Then
    strGroupDesc = "Global "
  ElseIf objGroup.GroupType AND ADS_GROUP_TYPE_UNIVERSAL_GROUP Then
    strGroupDesc = "Universal "
  Else
    strGroupDesc = "Unknown "
  End If
  If objGroup.GroupType AND ADS_GROUP_TYPE_SECURITY_ENABLED Then
    strGroupDesc = strGroupDesc & "Security group"
  Else
    strGroupDesc = strGroupDesc & "Distribution group"
  End If

  ' Check if there are members
  err.clear
  arrMemberOf = objGroup.GetEx("Member")
  If Err.Number = E_ADS_PROPERTY_NOT_FOUND then
    ' Write a line to the outputfile with group properties and no members
    objMyOutput.WriteLine(strGroupName & vbtab & strGroupDesc & vbtab & "<null>" & vbtab & "<null>")
  Else
    ' For each group member, get member properties
    For Each strMemberOf in arrMemberOf
      Set objMember = GetObject("LDAP://" & strMemberOf)
      strMemberName = right(objMember.Name,len(objMember.Name)-3)
      ' Write a line to the outputfile with group and member properties
      objMyOutput.WriteLine(strGroupName & vbtab & strGroupDesc & vbtab & strMemberName & vbtab & objMember.Class)
      set objMember = nothing
    Next
  End If
  objRecordSet.MoveNext
  Set objGroup = nothing
Loop
objMyOutput.close
wscript.echo "Done!"

Open in new window

0
 

Author Comment

by:nav2567
ID: 36587711
Thanks shabarinath and yo bee.

shabarinath, would you advise my powershell question again?

Thanks.
0
 
LVL 14

Accepted Solution

by:
Shabarinath Ramadasan earned 1500 total points
ID: 36588784
You need to install quest commandlets for active directory and run this query from its shell.
Once you install it , you could find it on program files - quest folder.

Not mandatory to run it from a dc or run this query with a user who have admin privilege.
you can run this query from any computer in the domain where quest commandlets is installed.

Try installing it on your destop, and you love it.

http://www.quest.com/powershell/activeroles-server.aspx

Shaba
0
 

Author Comment

by:nav2567
ID: 36594102
Free?  :-)
0
 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
ID: 36595570
Quest Command-lets for AD is freeware.
Enjoy
0
 

Author Closing Comment

by:nav2567
ID: 36952981
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question