locked
Finding DL's containing a specific domain RRS feed

  • Question


  • Our environment is Exchange 2007 SP3, but we have migrated our IT and other selected users to Exchange 2010 which we are rolling out. Our domain is exchange.com

    We have several hundred Exchange distribution lists. Some of these contain external recipients (partner companies etc).

    We have a partner company, domain.com, that we sometimes do business with. Some of their contacts are members of our DL's. Management have decided that they no longer want ANY domain.com addresses as members of our DL's.

    Does anyone know a Powershell command I can run that will search ALL DL's and provide a list where this is any domain.com recipient in them?

    And do we need to run this on an Exchange 2007 or Exchange 2010 machine, or does it not matter?

    Wednesday, October 19, 2011 7:29 AM

Answers

  • So if I got it correctly, domain.com is mailcontact with ExternalEmailAddress end with @domain.com

     

    The following will give some clues to you. The script will look for all the Distribution Group in existing Exch Org and filter only mailcontact with ExternalEmailAddress end with @domain.com, followed by display the DG displayname, domain.com mailcontact's alias and domain.com mailcontact's ExternalEmailAddress

     

    Get-DistributionGroup -ResultSize unlimited | ForEach-Object{ $dlmember = Get-DistributionGroupMember $_ | where {$_.recipienttype -eq "MailContact" -and $_.ExternalEmailAddress -match "domain.com$"};$_.displayname, $dlmember.alias, $dlmember.ExternalEmailAddress}

     

    You can edit the output you want accordingly. You can run it from Exchange 2007/Exchange 2010. It should work fine provided both E2K7 and E2K10 are in the same Exch. Org.



    • Edited by shuen100 Thursday, October 20, 2011 7:22 AM
    • Proposed as answer by Sophia Xu Friday, October 21, 2011 7:21 AM
    • Marked as answer by Sophia Xu Tuesday, October 25, 2011 6:15 AM
    Thursday, October 20, 2011 7:16 AM

All replies

  • Hi,

    If you have the list of users from the domain you can use the dsget user -memberof -expand command to list the groups these users are member of.

    Leif

    Wednesday, October 19, 2011 7:56 AM
  • So if I got it correctly, domain.com is mailcontact with ExternalEmailAddress end with @domain.com

     

    The following will give some clues to you. The script will look for all the Distribution Group in existing Exch Org and filter only mailcontact with ExternalEmailAddress end with @domain.com, followed by display the DG displayname, domain.com mailcontact's alias and domain.com mailcontact's ExternalEmailAddress

     

    Get-DistributionGroup -ResultSize unlimited | ForEach-Object{ $dlmember = Get-DistributionGroupMember $_ | where {$_.recipienttype -eq "MailContact" -and $_.ExternalEmailAddress -match "domain.com$"};$_.displayname, $dlmember.alias, $dlmember.ExternalEmailAddress}

     

    You can edit the output you want accordingly. You can run it from Exchange 2007/Exchange 2010. It should work fine provided both E2K7 and E2K10 are in the same Exch. Org.



    • Edited by shuen100 Thursday, October 20, 2011 7:22 AM
    • Proposed as answer by Sophia Xu Friday, October 21, 2011 7:21 AM
    • Marked as answer by Sophia Xu Tuesday, October 25, 2011 6:15 AM
    Thursday, October 20, 2011 7:16 AM
  • Hi,

    I have tested Shuen's command and it works fine.

    Thanks


    Sophia Xu
    Friday, October 21, 2011 7:22 AM