We help IT Professionals succeed at work.

How export members of one DL that have members across different domains?

I'm trying to export the current members of a DL for a request.  
I have tried the following old bat file but it only pulls the users on the domain of the server I'm on.
'=====================
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strUserDomain = wshNetwork.UserDomain
strUserComputer = wshNetwork.ComputerName
strUserName = wshNetwork.UserName

strGroup = InputBox("Please type the AD group name to get members of:", "Group Name", "mf_users")
Set objWinntObject = GetObject("WinNT://" & strUserDomain & "/" & strGroup)

strResults = "Results" & VbCrLf & "======="
strResults = strResults & VbCrLf & "Group: " & objWinntObject.Name
strMembers = GetMembers(GetObject("WinNT://" & strUserDomain & "/" & objWinntObject.Name))
strResults = strResults & VbCrLf & strMembers & VbCrLf

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile("DomainGroups.txt", True)
objOutputFile.Write strResults
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing

MsgBox "Done.  Please see output text file."

Function GetMembers(objGroup)      
      strMembers = ""
      
      For Each objMember In objGroup.Members
            If strMembers = "" Then
                  strMembers = objMember.Name
            Else
                  strMembers = strMembers & VbCrLf & objMember.FullName
            End If
      Next
      GetMembers = strMembers
End Function
'=====================

Open in new window


I've tried using the Query search within ADUC looking for the Member of "distinguishedName" but still that query is not pulling all the members. [and I which to the different domains]

I tried this cmd to view the members to see if its displays all the members across all the domains: Get-DistributionGroupMember –identity “group name” | ft name, primarysmtpaddress

But again no...what cmd can I run that will ensure I'm pulling all members into a cvs file for all 3 domains?

Thanks
Comment
Watch Question

Manpreet SIngh KhatraSolutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013

Commented:
Get-DistributionGroup | Get-DistributionGroupMember | FT Name, *Member* > DL.cvs or txt

- Rancy

Author

Commented:
So where do I put in the name of the group where I want to export the members?
Manpreet SIngh KhatraSolutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013

Commented:
Manpreet SIngh KhatraSolutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013

Commented:
Are you trying to Export members of one Distribution List or all ?

- Rancy

Author

Commented:
Just one DL

Author

Commented:
This cmd is not pulling all the members across other domains.
Get-DistributionGroupMember –identity “group name” | ft name, primarysmtpaddress > c:\members.csv

It just seems to pull the name of the members of the same domain I'm running the cmd from
Manpreet SIngh KhatraSolutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013

Commented:
Get-DistributionGroup -Identity "DL Name" | Get-DistributionGroupMember | FT Name, *Member*

The Get-DistributionGroupMember command does not return all the members of distribution group if there are multiple Active Directory domains in your topology environment
http://support.microsoft.com/kb/975555


- Rancy
Manpreet SIngh KhatraSolutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013

Commented:
To resolve this issue, follow these steps:

    Open Exchange Management Shell.
    Type the following command at the command line:
    Set-ADServerSettings -ViewEntireForest $True
    Note The Set-ADServerSettings command is a new command in Exchange Server 2010. By default, the ViewEntireForest parameter is set to False.
    Run the Get-DistributionGroupMember command to retrieve all the members of the distribution group.

- Rancy

Author

Commented:
Set-ADServerSettings -ViewEntireForest $True is for Exchange 2010 and I get an error when attempting to perform this task against Exchange 2007
Solutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013
Commented:
How to Change the Recipient Scope
http://technet.microsoft.com/en-us/library/bb124791%28v=EXCHG.80%29.aspx

$AdminSessionADSettings
ViewEntireForest (What is this set to ??)


http://exchangeserverpro.com/how-to-modify-recipient-scope-in-the-exchange-management-shell

- Rancy
Manpreet SIngh KhatraSolutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013

Commented:
Did that help ..... sorry work a lot with E2k10 so :)

- Rancy

Author

Commented:
Thanks Rancy...it helped big time.  No reason to be sorry...lol
Thanks again for your insight

Commented:
iGnore me.
avator.png