Add Distribution Group Member in Exchange Online

A_Lop 41 Reputation points
2021-12-03T19:24:17.103+00:00

Hello I was working on Migrate Distribution Groups from Exchange On-Premise to Exchange Online and somehow got stuck on one of the Exchange Online PowerShell commands. This is what I have so far:

PS C:\Users\AdminGlobal > Import-Csv C:\Users\AdminGlobal\Desktop\DistributionListProject\distributiongroups-and-members_modified.csv | ForEach-Object{

> $RecipientTypeDetails=$.GroupType
> $GroupSMTP=$
.NEWGroupSMTP
> $MemberSMTP=$_.NEWMemberSMTP
>
> if ($RecipientTypeDetails -eq "MailUniversalDistributionGroup")
> {
> Add-DistributionGroupMember -Identity $GroupSMTP -Member $MemberSMTP
> }
> }

After running the command, I received these errors below:

Couldn't find object "NEWTEST_ALL_2@keyman .com". Please make sure that it was spelled correctly or specify a
different object.

  • CategoryInfo : NotSpecified: (:) [Add-DistributionGroupMember], ManagementObjectNotFoundException
  • FullyQualifiedErrorId : [Server=B7765,RequestId=d21e8a116-7dd04c3ac88a,TimeStamp=12/3/2021
    6:59:07 PM] [FailureCategory=Cmdlet-ManagementObjectNotFoundException] 643B0EA0,Microsoft.Exchange.Management.Rec
    ipientTasks.AddDistributionGroupMember
  • PSComputerName : outlook.office365.com

In my .csv file, I made sure that the object "NEWTEST_ALL_2@keyman .com" is available under the column header specified "NEWMemberSMTP"

I need help in figuring this out and hoping to get some answers.

My reference in this project is this website: https://www.catapultsystems.com/blogs/migrate-distribution-groups-from-exchange-on-premise-to-exchange-online/#

Not sure if anyone is familiar with this site and has used this, but I am currently on Step 3 Exchange Online: create “NEW” distribution groups, hide from GAL, and add members, Exchange Online: Add Members to Groups.

Thank you.

Exchange | Exchange Server | Development
Exchange | Exchange Server | Management
{count} votes

3 answers

Sort by: Most helpful
  1. Andy David - MVP 157.8K Reputation points MVP Volunteer Moderator
    2021-12-03T22:01:57.413+00:00

    What is returned for in Exchange Online Powershell for :
    Get-DistributionGroup NEWTEST_ALL_2@keyman .com


  2. KyleXu-MSFT 26,396 Reputation points
    2021-12-06T08:06:23.537+00:00

    @A_Lop

    I guess this issue is caused by nested group, such as:

    Group2 is a member of Group1. In the script, it creates Group1 first(Group 2 isn't created so far), then this script try to add members to Group1, due to group2 isn't created, a issue will occur.

    You could add "-erroraction 'silentlycontinue'" to the script that you used, in this way, it will bypass non-existent user/group and keep script running. But, you will need to modify some groups manually later.

    Add-DistributionGroupMember -Identity $GroupSMTP -Member $MemberSMTP  
    

    Otherwise, you may need to find another script which create all groups first, then add members to those groups.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.



  3. A_Lop 41 Reputation points
    2021-12-15T04:13:03.183+00:00

    That should be the same concept though, although I ran the script on the first step to create the group in the cloud. Doing it manually would be the same thing, I would think?

    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.