We help IT Professionals succeed at work.
Get Started

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

Last Modified: 2012-08-11
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
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
                  strMembers = strMembers & VbCrLf & objMember.FullName
            End If
      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?

Watch Question
Solutions Architect, Project Lead
Top Expert 2013
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE