Distribution Lists

Welcome Forums General PowerShell Q&A Distribution Lists

Viewing 1 reply thread
  • Author
    • #279810
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member


      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?


    • #280371
      Topics: 1
      Replies: 59
      Points: 584
      Helping Hand
      Rank: Major Contributor

      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.

      • This reply was modified 1 month ago by AndySvints.
Viewing 1 reply thread
  • You must be logged in to reply to this topic.