Distribution Lists


2 companies share 3 domains and should be kept separate most of the time for distribution lists etc.
It is clear we have users from company a in company b’s lists which is wrong.
We are talking about 100’s, if not 1000’s of lists here.

I need to be able to search all 3 domains lists (and mail enabled security groups) with @company email address for any @companyb UPN and export the lists with members to review as a few may actually need to be a member.

Once reviewed, then remove the x users.

What’s the best way of doing this?


Hello nenick39,

One way would be to get all Distribution Groups and mail enabled security groups using Get-DistributionGroup. Then foreach group get distribution group members using Get-DistributionGroupMember recursively ( as member of a group could be another group). Then foreach member get his/her email address and apply your filter based on domain name and create custom PS object which will contain couple of properties: DLName, DLEmailAddress, ContainsCompanyAMembers, ContainsCompanyBMembers,ContainsCompanyCMembers.
Add all objects to List and output to file csv/html.
This type of report will be a starting point to understand how many Distribution Group you have to fix/adjust.

Hope that helps.