Solved

list members in distribution group

Posted on 2011-09-21
9
538 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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

691 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