How to Export Members of Exchange Distribution List

I came across this nice VB script to export the list of members of a distribution list of exchange :

'Script begins here

Dim objGroup, objUser, objFSO, objFile, strDomain, strGroup, Domain, Group

'Change DomainName to the name of the domain the group is in
strDomain = Inputbox ("Enter the Domain name", "Data needed", "Default domain name")
'Change GroupName to the name of the group whose members you want to export
strGroup = InputBox ("Enter the Group name", "Data needed", "Default group name")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'On the next line change the name and path of the file that export data will be written to.
Set objFile = objFSO.CreateTextFile("C:\Bin\" & strGroup & " - Members.csv")
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
For Each objUser In objGroup.Members
    objFile.WriteLine objUser.Name & " - " & objUser.Class
Next
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set objUser = Nothing
Set objGroup = Nothing
Wscript.Echo "Done"
Wscript.Echo "Please check the c: for your output file"

Note: The script will ask you the domain name and the group the distribution group for which member list to be created.

No comments:

Post a Comment

Popular Posts