net group "Name of Dist List" >c:\dist.txt would not give the Contacts who are members of that DL. Also it would be difficult to find the email addresses.
To retrieve the membership of a Distribution list to a file. (FullName,Sam Account,e-Mail ) use the below script.
On Error Resume Next
strPath = inputbox("Please enter in the path to your group in AD")
Set objGroup = GetObject ("LDAP://" & strPath)
objGroup.GetInfo
strArrMember = objGroup.GetEx("member")
dim fs,objWriteFile
set fs=CreateObject("Scripting.FileSystemObject")
set objWriteFile = fs.CreateTextFile("GrpMem.csv", True)
dim objDistinguishedName
objWriteFile.Write "FullName,Sam Account,e-Mail" & vbcrlf
For Each strMember in strArrMember
Set objUser = GetObject ("LDAP://" & strMember) objWriteFile.Write objUser.FullName & "," & objUser.sAMAccountName & "," & objuser.mail & vbcrlf
Mukul
No comments:
Post a Comment