Solved

How to filter out all the mail-enabled groups?

Posted on 2009-07-13
3
291 Views
Last Modified: 2012-05-07
Hello,

I am looking for a script to list all the mail-enabled groups and export them in an excel sheet.

Thanks
0
Comment
Question by:amyassein
3 Comments
 
LVL 57

Accepted Solution

by:
Mike Kline earned 500 total points
ID: 24837813
I like adfind by MVP Joe Richards
http://www.joeware.net/freetools/tools/adfind/index.htm

adfind -default -f  "&(objectcategory=group)(mail=*)"  displayname mail -csv -nodn > c:\mailEnabled.csv
That will give you a csv on your C drive.
 
I also helped with a similar question earlier this year
http://www.experts-exchange.com/Database/LDAP/Q_24100116.html
Thanks
Mike
0
 
LVL 27

Expert Comment

by:bluntTony
ID: 24839082
Just for completeness, the below is a simple VB script will produce a report of all mail enabled groups and their location in your domain.

Save as a vbs and run via cscript, e.g:

cscript getAllMailEnabledGroups.vbs

To output to a text file:

cscript getAllMailEnabledGroups.vbs > results.txt

Tony


Set objRoot = GetObject("LDAP://RootDSE")

strBase = "<LDAP://" & objRoot.get("defaultNamingContext") & ">;"

strFilter = "(&(objectclass=group)(mail=*));" 

strAttrs  = "distinguishedName;"

strScope  = "subtree"
 

Set objConn = CreateObject("ADODB.Connection")

Set objComm =   CreateObject("ADODB.Command")

objConn.Provider = "ADsDSOObject"

objConn.Open "Active Directory Provider"

Set objComm.ActiveConnection = objConn

objComm.Properties("Page Size") = 1000

objComm.CommandText = strBase & strFilter & strAttrs & strScope

Set objRS = objComm.Execute
 

If objRs.RecordCount > 0 Then

	objRS.MoveFirst

	Do

		Set objGroup = GetObject("LDAP://" & Replace(objRS.Fields(0).Value,"/","\/"))

		WScript.Echo objGroup.cn & String(40-Len(objGroup.cn)," ") & " : (" & objGroup.distinguishedName & ")"

		objRS.MoveNext

	Loop Until objRS.EOF

End If
 

Set objRoot = Nothing

Set objComm = Nothing

Set objConn = Nothing

Set objGroup = Nothing

Set objRS = Nothing

Open in new window

0
 
LVL 1

Author Comment

by:amyassein
ID: 24848109
bluntTony,

VBScript Runtime Error: "Invalid procedure call or argument: 'String'"

Any ideas?
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Resolve DNS query failed errors for Exchange
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now