Solved

How to filter out all the mail-enabled groups?

Posted on 2009-07-13
3
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Office 365 Advanced Training for Admins

Special Offer:  Buy 1 course, get 2nd free!  Buy the 'Managing Office 365 Identities & Requirements' course w/ Accelerated TestPrep, and automatically receive the 'Enabling Office 365 Services' course FREE!

Question has a verified solution.

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

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 …
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

738 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