Unified Group membership

Glenn Maxwell 10,146 Reputation points
2024-04-19T05:10:35.3766667+00:00

Hi All

i have created unified group using the below syntax.

New-UnifiedGroup -DisplayName "UG1" -Alias "UG1" -PrimarySmtpAddress "UG1@contoso.com" -Members "user1@contoso.com","user2@contoso.com" -ManagedBy "user1@contoso.com","user2@contoso.com"

I want to add user3@contoso.com & user4@contoso.com as the owner of the unfied group and remove user1 & user2.

I want to add user5@consoto.com & user6@contoso.com as the members and remove user1 & user2. i have two csv files one as owner and one as member, how can i import the csv file and make the changes using powershell please guide me.

owners

members

Microsoft Exchange Online
Exchange Server
Exchange Server
A family of Microsoft client/server messaging and collaboration software.
1,082 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,189 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,355 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,895 questions
0 comments No comments
{count} votes

Accepted answer
  1. Noah Ma-MSFT 610 Reputation points Microsoft Vendor
    2024-04-19T10:07:25.4266667+00:00

    Hi @Glenn Maxwell,

    Based on your description, you could use this command to add/remove user via CSV:

    For add:

    Import-CSV "C:\members.csv" | ForEach-Object {Add-UnifiedGroupLinks –Identity "XXX" –LinkType Members  –Links $_.member}

    For remove:

    Import-CSV "C:\members.csv" | ForEach-Object {Remove-UnifiedGroupLinks –Identity "XXX" –Links $.member –LinkType Members -Confirm:$false Write-Host "The user" $.member "removed"}

    Here is the sample CSV:

    A screenshot of a computer

    However, I suggest you can do it step by step since you just need to tack action on a small number of users.

    Note: You can’t add an Owner straight away to group, first you will have to make it a member of the group and then you can change the role to owner.

    So we add [user3@contoso.com] & [user4@contoso.com] and [user5@contoso.com] & [user6@contoso.com] as the member first, run this command:

    Add-UnifiedGroupLinks -Identity "XXX" -LinkType Members -Links [user3@consoto.com], [user4@consoto.com], [user5@consoto.com], [user6@consoto.com]

    Then change [user3@contoso.com] & [user4@contoso.com] the role to Owner, run this command:

    Add-UnifiedGroupLinks -Identity "XXX" -LinkType Owners -Links [user5@consoto.com], [user6@consoto.com]

    To remove user1 & user2, run this command:

    Remove-UnifiedGroupLinks -Identity "XXX" -LinkType Members -Links [user1@consoto.com], [user2@consoto.com]

    For more information you can refer to the documents below:

    Add-UnifiedGroupLinks (ExchangePowerShell) | Microsoft Learn

    Remove-UnifiedGroupLinks (ExchangePowerShell) | Microsoft Learn

    0 comments No comments

0 additional answers

Sort by: Most helpful