Solved

How to filter out all the mail-enabled groups?

Posted on 2009-07-13
3
292 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
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 …

776 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