Find Empty Distribution Lists
I’m running a Server with Domain at small office premises. I need to find out all available Mail Enabled Groups or Distribution Lists from my Domain which are without any members. I need to get this entire list on a file but not getting it done. So I request you people to provide and easy method for doing the same.
Thanks in advance.
Re: Find Empty Distribution Lists
Hello friend. Yes, you can do it using an ADO. For the doing the same you need to create filter like this:
Quote:
"(&(objectCategory=group)" _
& "(!groupType:1.2.840.113556.1.4.803:=2147483648)" _
& "(!memberOf=*))"
If you somewhere feel need for a script which dumps out both the NT name and Distinguished Names of all such groups, then here is the same:
Quote:
=============
Option Explicit
Dim objRootDSE, strDNSDomain, objCommand, objConnection
Dim strBase, strFilter, strAttributes, strQuery, objRecordSet
Dim strNTName, strDN
' Determine DNS domain name.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use ADO to search Active Directory.
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"
' Filter on distribution groups with no members.
strFilter = "(&(objectCategory=group)" _
& "(!groupType:1.2.840.113556.1.4.803:=2147483648)" _
& "(!memberOf=*))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "sAMAccountName,distinguishedName"
' Construct the ADO query, using LDAP syntax.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
' Run the query.
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
' Enumerate the recordset and output the values retrieved in
' comma delimited format.
Do Until objRecordSet.EOF
strNTName = objRecordSet.Fields("sAMAccountName").Value
strDN = objRecordSet.Fields("distinguishedName").Value
Wscript.Echo strNTName & "," & strDN
objRecordSet.MoveNext
Loop
objRecordSet.Close
' Clean up.
objConnection.Close
Set objRootDSE = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRecordSet = Nothing
============
Re: Find Empty Distribution Lists
That was great script 'unidentified' but let me correct you a bit. If i am not wrong you mean to say member attribute (the forward-link) not memberOf (the back-link), right?
Re: Find Empty Distribution Lists
Active Directory Plus allows you to list groups dependent any number of members, and then export the data to txt or excel file.