Solved

How to filter out all the mail-enabled groups?

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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 …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

617 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