Exchange 2010 - show users NOT in a distribution list

Posted on 2011-04-27
Last Modified: 2012-05-11
Is there some way, with PowerShell or otherwise, to get a list of all users who are NOT in a particular distribution list?  I have a distribution list of users who are not allowed to send/receive external email.  I would like a list of all the users/email addresses that are NOT in that list (ie. those that can send/receive external email).  Is there a way to do that in Exchange 2010?

Question by:bruno71
    LVL 4

    Accepted Solution


    Run this command from AD (Command Prompt). TO pull the exact  attribute of the Distribution group, go to ADUC > right click the distribution group > Properties > Attribute Editor > Distinguished Name > Copy and Paste it ahead of !memberof=cn parameter.

    DSQuery * -Filter "(&(objectCategory=user)(!memberOf=CN=xxxxx,OU=xxxx,OU=xxxx,DC=xxx,DC=xx,DC=xx))" -Attr samAccountName -Limit 0
    LVL 12

    Expert Comment

    Or the Powershell way (with Quest free cmdlets).
    get-QADUser -SearchRoot 'DC=My,DC=Company,DC=local' -NotMemberOf 'DOMAIN\NoSoup4You'

    Or to check for nested members... SLOWER.
    get-QADUser -SearchRoot 'DC=My,DC=Company,DC=local' -NotIndirectMemberOf 'DOMAIN\Group'


    Author Comment

    Thanks paritoshjani.  That worked.  I tweaked it a little to give me the email address and then exported it to a text file.

    DSQuery * -Filter "(&(objectCategory=user)(!memberOf=CN=xxxxx,OU=xxxx,OU=xxxx,DC=xxx,DC=xx,DC=xx))" -Attr mail -Limit 0 > c:\textfile.txt


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Exchange 2010 DAG Node 2 14
    ost file sizes 7 31
    Does Experts Exchange validate user's IP addresses? 3 14
    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now