Unified Group membership

Glenn Maxwell 12,256 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 "******@contoso.com" -Members "******@contoso.com","******@contoso.com" -ManagedBy "******@contoso.com","******@contoso.com"

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

I want to add ******@consoto.com & ******@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,435 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,735 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,787 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.
2,219 questions
0 comments No comments
{count} votes

Accepted answer
  1. Noah Ma-MSFT 2,725 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 [@contoso.com] & [@contoso.com] and [@contoso.com] & [@contoso.com] as the member first, run this command:

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

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

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

    To remove user1 & user2, run this command:

    Remove-UnifiedGroupLinks -Identity "XXX" -LinkType Members -Links [@consoto.com], [@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

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.