Solved

list members in distribution group

Posted on 2011-09-21
9
530 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
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
 
LVL 22

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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 500 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

895 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now