How to Add Members to Office 365 Group using PowerShell?

Requirement: Add members to the Office 365 group using PowerShell

How to add users to Office 365 Group using Admin Center?

Microsoft 365 groups help you collaborate and share information with colleagues, clients, or customers. This post will show you how to add a member to a Microsoft 365 group using the Microsoft Admin Center. Also, we will show you how to add a member to an Office 365 group by using PowerShell. Let’s get started!

You can add members to any Office 365 group through Microsoft 365 admin center as an admin. Here is how:

  • Login to the Microsoft 365 Admin Center site: https://admin.microsoft.com
  • Expand Groups and Click on the Groups link in the left navigation. 
  • Select the Office 365 group you wish to add members
  • Click on the Edit link next to the Members column in the details pane.
    add user to office 365 group using powershell
  • On the Group page, Click on Add Members button >> Search and select users you wish to add to the group. You can find and add multiple users in a single stretch.
    how to add users to office 365 group powershell
  • Click on “Save” once you are done! You’ll see “Group membership was updated and will take effect immediately.” message.

How to Add Users to Office 365 Group using PowerShell?

To add a group member, You’ll need the group’s ID and the email address of the person you want to add as a member. Let’s add “[email protected]” to the “[email protected]” Office 365 group using PowerShell cmdlet Add-UnifiedGroupLinks.

#Get Credentials to connect
$Credential = Get-Credential
 
#Connect to Exchange Online
Connect-ExchangeOnline -Credential $Credential -ShowBanner:$False

#PowerShell to add a user to office 365 group
Add-UnifiedGroupLinks -Identity "[email protected]" -LinkType "Members" -Links "[email protected]"

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

Bulk Add Members to Office 365 Group using PowerShell

Likewise, you can add multiple users comma separated. E.g.

Add-UnifiedGroupLinks -Identity "[email protected]" -LinkType "Members" -Links "[email protected]","[email protected]

Add Group Member to SharePoint Online Site:

Here is how to add a group member to the associated group of a given SharePoint Online site.

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Legal"
$UserID = "[email protected]"

#Connect to Exchange Online
Connect-ExchangeOnline -ShowBanner:$False

#Get the Office 365 group of the SharePoint site
$Group = Get-UnifiedGroup -ResultSize Unlimited | Where { $_.SharePointSiteUrl -eq $SiteURL}

#Add Group Member
Add-UnifiedGroupLinks -Identity $Group.DistinguishedName -LinkType Members -Links $UserID

PnP PowerShell to Add Users to SharePoint Online Site’s Associated Members Group

This time, let’s add the user to the associated Microsoft 365 Group member using PnP PowerShell:

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/CorporateBranding"
$SiteOwner= "[email protected]"
 
Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive
 
    #Get the Site
    $Site = Get-PnPSite -Includes GroupId
      
    #Add user to the Site's associated Microsoft 365 Group Member
    Add-PnPMicrosoft365GroupMember -Identity $Site.GroupId -Users $SiteOwner
    Write-host "Added Member to the Associated Microsoft 365 Group!" -f Green    
}
Catch {
    Write-host -f Red "Error:" $_.Exception.Message
}

PowerShell to Add Users to Office 365 Group from CSV

Here is how to bulk-add members to Office 365 group from a CSV file using PowerShell:

PowerShell to Add Users to Office 365 Group from CSV

Import Office 365 Group members from CSV File:

#Get Credentials to connect
$Credential = Get-Credential
 
#Connect to Exchange Online
Connect-ExchangeOnline -Credential $Credential -ShowBanner:$False

#PowerShell to Import Members to office 365 group from CSV
Import-CSV "C:\Temp\GroupMembers.csv" | ForEach-Object {
    Add-UnifiedGroupLinks -Identity $_.GroupID -LinkType Members -Links $_.Member
    Write-host -f Green "Added Member '$($_.Member)' to Office 365 Group '$($_.GroupID)'"
}

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

To add an owner to Office 365 group, use: How to Add Owner to Office 365 Group using PowerShell?

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

5 thoughts on “How to Add Members to Office 365 Group using PowerShell?

  • I’m running into a problem with this, and I am not sure if this is where to turn, but because Microsoft’s naming scheme for services has become increasingly confusing, googling for help hasn’t been much use, nor has Microsoft’s documentation.

    With the help of this blog I have been able to run a script that will add users to my Office365 group, but only if they are internal users or existing contacts.

    I am trying to bulk add about 120 guest users to an Office365 group without them having to click an invitation (they’re already on a listserv but the server died; long story).

    The problem I am running into is that apparently they have to already exist as guest users in the Azure AD tenant.

    Is there a way to bulk add guests to the tenant without them needing to accept the invitation/click on something first?

    Reply
  • Is there a way to suppress notification email when you add?

    Reply
  • Thanks for the article. Very helpful.
    Can you please help on how I can add a user to multiple O365 groups?

    Thank You!

    Reply
  • I am following your guide “Import Office 365 Group members from CSV File”,
    But it’s giving me the following error;

    Add-UnifiedGroupLinks: A positional parameter cannot be found that accepts argument ‘[email protected]’.

    Please help.

    Reply

Leave a Reply