Others

How to Bulk Add and Remove Microsoft 365 Group Members with PowerShell

Natalie TaylorNatalie Taylor Nov 13, 2026 869 views

Question details

The user needs PowerShell automation to process a defined list of Microsoft 365 groups, remove existing owners and members, and add two specified users as owners.

How to Bulk Add and Remove Microsoft 365 Group Members with PowerShell
Product
Microsoft 365 / Exchange Online
Device & OS
not provided
Scenario
The user manages multiple Microsoft 365 groups and wants to automate a bulk owner and member replacement without manually editing each group.
Observed behavior
Groups currently contain existing owners and members; the required end state is to remove all existing owners and members and add two specified users as owners.
Before you start

Before running any bulk Microsoft 365 group script, confirm that your account has Exchange Online Administrator or Groups Administrator permissions, install the required PowerShell module, and run the script against one test group first.

Solution 1Recommended

Bulk Replace Owners and Members with Exchange Online PowerShell

Use this when you manage groups through Exchange Online admin tools and need a direct foreach loop over a specified group list.

This approach uses the ExchangeOnlineManagement module and the Exchange Online group cmdlets Get-UnifiedGroup, Remove-UnifiedGroupLinks, and Add-UnifiedGroupLinks. Because Microsoft 365 group cmdlets and tenant permissions vary, run the script on a small test group before processing all production groups.

1
Install and import Exchange Online module

Open Windows PowerShell as administrator and run Install-Module ExchangeOnlineManagement -Force, then Import-Module ExchangeOnlineManagement.

2
Connect to Exchange Online

Run Connect-ExchangeOnline and sign in with an account that has Exchange Online Administrator or Groups Administrator permissions.

3
Define the group and owner list

Create a CSV file or array containing each Microsoft 365 group email address and the two users you want to add as owners.

4
Remove existing group owners and members

Inside a foreach loop, run $group = Get-UnifiedGroup -Identity $GroupEmail; then Remove-UnifiedGroupLinks -Identity $GroupEmail -LinkType Members -Links $group.Members; and Remove-UnifiedGroupLinks -Identity $GroupEmail -LinkType Owners -Links $group.Owners.

5
Add the two specified users as owners

In the same loop, run Add-UnifiedGroupLinks -Identity $GroupEmail -LinkType Owners -Links user1@contoso.com,user2@contoso.com.

6
Verify and test the result

Run Get-UnifiedGroupLinks -Identity $GroupEmail -LinkType Owners to confirm only the two specified owners are listed, and test the script on one small group before running it against all groups.

Bulk Replace Owners and Members with Exchange Online PowerShell
Test on a small group first: Permissions and cmdlet behavior can vary by tenant. Test the script on a small Microsoft 365 group and review the resulting owner and member lists before processing your full production list.
Free Microsoft Office alternative

Use WPS Office as a Free Alternative for Daily Microsoft 365 Document Editing

WPS Office does not manage Microsoft 365 group membership or run Exchange Online PowerShell commands. If your daily work mainly involves creating and editing documents, WPS Office provides a free, lightweight Office alternative with familiar tools and seamless Microsoft Office format compatibility.

  1. 1. Download WPS Office: Go to the official WPS Office website and download the free installer for Windows, macOS, or your supported device.
  2. 2. Install and open WPS Office: Run the installer, open WPS Office, and sign in or create a WPS account when prompted.
  3. 3. Open and edit Microsoft Office files: Use Writer, Spreadsheets, or Presentation to open, edit, and save Word, Excel, and PowerPoint files directly.
Full read/write compatibility with Word, Excel, PowerPoint, and PDF filesFree and lightweight Office suite that runs on Windows, macOS, Android, iOS, and LinuxFamiliar ribbon-style interface makes switching from Microsoft Office easyReduces dependence on complex Microsoft 365 admin and PowerShell tasks for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Which PowerShell module is best for bulk-changing Microsoft 365 group owners and members?

Start with the ExchangeOnlineManagement module because it has Get-UnifiedGroup, Remove-UnifiedGroupLinks, and Add-UnifiedGroupLinks. If your tenant uses Microsoft Graph permissions, use the Microsoft.Graph module with Group.ReadWrite.All.

Why do I get a permission error when running the bulk group script?

You likely need the Exchange Online Administrator or Groups Administrator role. Run Connect-ExchangeOnline with an account that has the required role, or use an admin account for Connect-MgGraph and consent to Group.ReadWrite.All.

Can WPS Office manage Microsoft 365 group owners and members?

No. WPS Office is a free Office suite for document editing and does not provide Microsoft 365 admin or Exchange Online PowerShell group management. Use Microsoft 365 admin tools for group membership.

How can I avoid deleting the wrong Microsoft 365 group owners in a bulk script?

Export the current owners and members to a CSV backup first, process one test group, and then verify the result with Get-UnifiedGroupLinks or Get-MgGroupOwner before running the full list.