Results 1 to 4 of 4

Thread: Find Empty Distribution Lists

  1. #1
    Join Date
    Jul 2005
    Posts
    36

    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.

  2. #2
    Join Date
    Sep 2005
    Posts
    1,476

    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:

    "(&(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:

    =============

    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

    ============

  3. #3
    Join Date
    Jan 2006
    Posts
    605

    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?

  4. #4
    Join Date
    Sep 2010
    Posts
    5

    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.

Similar Threads

  1. How to create Outlook Distribution lists in Excel VBA
    By YajasK in forum MS Office Support
    Replies: 2
    Last Post: 17-02-2012, 06:02 PM
  2. How to find total number of duplicates from lists of sheet in excel
    By Kungfu Pandey in forum MS Office Support
    Replies: 2
    Last Post: 08-01-2012, 05:21 PM
  3. Mass deletion of distribution lists via AD
    By SimonH in forum Windows Software
    Replies: 1
    Last Post: 06-10-2011, 03:05 PM
  4. Find delete empty registry keys
    By Conner in forum Operating Systems
    Replies: 3
    Last Post: 28-05-2009, 12:09 AM
  5. Distribution Groups - export lists and members
    By Isaivalan in forum Active Directory
    Replies: 2
    Last Post: 24-07-2007, 12:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,638,403,523.34361 seconds with 17 queries