How to Bulk Add and Remove Microsoft 365 Group Members with PowerShell
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.

- 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 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.
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.
Open Windows PowerShell as administrator and run Install-Module ExchangeOnlineManagement -Force, then Import-Module ExchangeOnlineManagement.
Run Connect-ExchangeOnline and sign in with an account that has Exchange Online Administrator or Groups Administrator permissions.
Create a CSV file or array containing each Microsoft 365 group email address and the two users you want to add as owners.
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.
In the same loop, run Add-UnifiedGroupLinks -Identity $GroupEmail -LinkType Owners -Links user1@contoso.com,user2@contoso.com.
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.

Use Microsoft Graph PowerShell SDK to Manage Group Owners
Use this alternative when your tenant is already using Microsoft Graph permissions or when you need API-based group management across Microsoft 365 workloads.
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. Download WPS Office: Go to the official WPS Office website and download the free installer for Windows, macOS, or your supported device.
- 2. Install and open WPS Office: Run the installer, open WPS Office, and sign in or create a WPS account when prompted.
- 3. Open and edit Microsoft Office files: Use Writer, Spreadsheets, or Presentation to open, edit, and save Word, Excel, and PowerPoint files directly.

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.




