Find DL List which having more then 100 members
I have 4000 Distributions List, How can I find the list of the Distribution List which has more then 100 members.Dinesh
August 16th, 2010 4:20pm
On Mon, 16 Aug 2010 13:20:47 +0000, Dinesh111 wrote:
>
>
>I have 4000 Distributions List, How can I find the list of the Distribution List which has more then 100 members.
Do you want to count members of nested groups, or just the number of
direct group members?
Probably the fastest way is to use the "range" and ask for the 1st 101
members. Then use the 'count' property of the COM object to see if
it's greater than 100.
Here's an example of using the range:
http://itchanged.com/GettingMembersOfLargeActiveDirectoryGroups.html
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2010 5:40am
Hi Rich,
Thanks for post, I want count the number of the members of the group. Is any LDAP query there.
Dinesh
August 17th, 2010 4:30pm
Hi Dinesh111,
Do you want to do this for recursive DLs? meaning nested DLs.
for eg.,
DL1 --100 members + 2 dls
you want to go and check those additional 2dls members and give that count as well?
thanks
ThiyaguThiyagu | MCTS/MCITP - Exchange 2007 | MCSE 2003[Messaging] | http://www.myExchangeWorld.com. This posting is provided "AS IS" with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2010 4:42pm
Anyway, here is the code to that for the recursive:
Const ADS_SCOPE_SUBTREE = 2
Const ForAppending = 8
Const ForReading = 1
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set SrvList = objFSO.OpenTextFile("DL_List.txt", ForReading)
set Reportfile =objFSO.CreateTextfile("Report_DL_Members.txt")
Reportfile.close
set Reportfile =objFSO.OpenTextFile("Report_DL_Members.txt",2)
i=0
Do Until SrvList.AtEndOfStream
strname=srvlist.readline
objCommand.CommandText = _
"SELECT DisplayName,sAMAccountName,distinguishedName FROM 'LDAP://dc=domain,dc=com' WHERE objectCategory='group' " & _
"AND displayname='" & strName & "'"
Set objRecordSet = objCommand.Execute
DN1= objRecordSet.Fields("distinguishedName").Value
Set objGroup = GetObject("LDAP://" & DN1)
For Each objMember in objGroup.Members
IF objmember.class="group" then
GET_DL_Members objmember.distinguishedName
else
i=i+1
end if
Next
Loop
wscript.echo strName & vbtab & " has " & i & " members"
reportfile.writeline strName & vbtab & " has " & i & " members"
Function GET_DL_Members(DN2)
Set objgroup1=GetObject("LDAP://" & DN2)
For Each objMember in ObjGroup1.Members
If objMember.class="group" then
GET_DL_Members objmember.distinguishedName
else
i=i+1
end if
Next
End Function
edit the ldap path to your own domain.
in the folder where you execute this script, create a file called dl_list.txt and then add the displaynames of the dl for wich you want to get the members count.
then run the script.
thanks
thiyaguThiyagu | MCTS/MCITP - Exchange 2007 | MCSE 2003[Messaging] | http://www.myExchangeWorld.com. This posting is provided "AS IS" with no warranties, and confers no rights.
August 17th, 2010 4:54pm
On Tue, 17 Aug 2010 13:30:07 +0000, Dinesh111 wrote:
>Thanks for post, I want count the number of the members of the group. Is any LDAP query there.
If you want to count ALL the members of a group you'll have to write
some code . . . unless you use Powershell. The reasone it's necessary
to write code is because the AD will only return 1000 (or 1500)
results at a time. You have to get the 1st batch and then query again
with the range starting at one more then the last member returned.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 4:02am
On Tue, 17 Aug 2010 13:54:36 +0000, Thiyagu14 wrote:
>Anyway, here is the code to that for the recursive:
The code won't work correctly for grops with large memberships. It'll
work okay for groups with up to 1,000 (or 1,500) members but it will
not work correctly for groups with memberships that exceed those
numbers.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
August 18th, 2010 5:11am
Thanks Rich & Thiyagu:
My query is How can I identify those DL which having more then 100 members out of 4000 DL in my domain.
Dinesh
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 4:18pm
Hi Dinesh,
My script does that, enter all the 4000 dl displaynames in that text file and run the script.
at the end , you will have the report file in that same folder where you run
this report will have the number of users for each of them. just paste in excel and you can easily do a filter for dls which has got more than 100 members
or you can tweak my script itself, (do u have any scripting experience at all?)
before i print the value in my script, you just have to put a condition if i > 100 then print that dl name.
let me know if you have any questions.
thanks
ThiyaguThiyagu | MCTS/MCITP - Exchange 2007 | MCSE 2003[Messaging] | http://www.myExchangeWorld.com. This posting is provided "AS IS" with no warranties, and confers no rights.
August 18th, 2010 9:05pm