I was looking for a sample script to query an AD security group and
export each users email address to a txt file or excel file? any help
would be great.

Re: Export Email Addresses from Active Directory Security Group by JTW

JTW
Thu Sep 14 16:48:07 CDT 2006

The below script is an basic example. You can build off this idea,
changing the data to match your environment:

strLDAP = "LDAP://CN=[Group],[CN or OU],DC=????,DC=???"

Set objItem = GetObject(strLDAP)
colMembers = objItem.GetEx("member")
ReDim aUsers(0)

For Each objMember In colMembers
Set objUser = GetObject("LDAP://" & objMember)
strEMail = strEMail & objUser.mail & vbCrLf
Next

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set tsFile = objFSO.OpenTextFile("C:\DEMO.TXT",2, True, -2)
tsFile.Write strEMail
tsFile.Close


--
Jase T. Wolfe
Dx21, LLC
http://www.Dx21.com


jaylock wrote:

> I was looking for a sample script to query an AD security group and
> export each users email address to a txt file or excel file? any help
> would be great.