mail enabled security group

Glenn Maxwell 12,871 Reputation points
2020-10-01T19:41:43.62+00:00

Hi All
I am using exchange 2010 hybrid environment, I have a csv file in the below format. I want to add the below users to mail enabled security group, will the below syntax work in exchange online and exchange 2010
users
user1@Company portal .com
user2@Company portal .com

Import-csv C:\userlist.csv | ForEach {Add-DistributionGroupMember -Identity group@Company portal .com -Member $_.users}

experts help me with the syntax to create a mail enabled security group from PowerShell in exchange 2010 and exchange online.

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Exchange Exchange Server Management
Exchange Hybrid management
{count} votes

Accepted answer
  1. Andy David - MVP 157.4K Reputation points MVP Volunteer Moderator
    2020-10-01T20:29:37.287+00:00

    To mail-enable an existing on-prem security group ( and this will sync to 365/ Exchange Online with AADConnect)

    Enable-DistributionGroup -Identity ******@contoso.com  
    

    Then to add the members:

    Import-csv C:\userlist.csv | % {Add-DistributionGroupMember -Identity ******@contoso.com -Member $_.users -BypassSecurityGroupManagerCheck}  
    

    The -BypassSecurityGroupManagerCheck is needed if you don't own the group, so it should typically always be used.

    More info:

    https://learn.microsoft.com/en-us/powershell/module/exchange/add-distributiongroupmember?view=exchange-ps


2 additional answers

Sort by: Most helpful
  1. Udara Peiris 701 Reputation points
    2020-10-01T20:32:52.02+00:00

    Your syntax should be worked.
    Please refer official document for further details.

    0 comments No comments

  2. Joyce Shen - MSFT 16,701 Reputation points
    2020-10-02T02:18:29.607+00:00

    Hi @Glenn Maxwell , agree with the replies above, first make sure you have on-premises security groups mail-enabled so that they will able to be synced to Exchange Online.

    Then run the command you provided above, they should work properly.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.