[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 550
  • Last Modified:

list members in distribution group

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
nav2567
Asked:
nav2567
1 Solution
 
ctc1900Commented:
0
 
Shabarinath RamadasanInfrastructure Specialist - MicrosoftCommented:
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
 
nav2567Author Commented:
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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
yo_beeDirector of ITCommented:
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
 
nav2567Author Commented:
Thanks shabarinath and yo bee.

shabarinath, would you advise my powershell question again?

Thanks.
0
 
Shabarinath RamadasanInfrastructure Specialist - MicrosoftCommented:
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
 
nav2567Author Commented:
Free?  :-)
0
 
Shabarinath RamadasanInfrastructure Specialist - MicrosoftCommented:
Quest Command-lets for AD is freeware.
Enjoy
0
 
nav2567Author Commented:
Thanks.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now