SharePoint Online: Copy/Move Users from One Group to Another

Requirement: Move users from one group to another in SharePoint Online.

How to Copy or Move Users Between SharePoint Online Groups?

Do you need to copy users from one group to another in SharePoint Online? Maybe you’ve just set up a new group and need to populate it with users from an existing group. Perhaps you want to move a user from one group to another. Whatever the reason, there are a few ways you can do this. This article will show you how to copy users from one group to another using PowerShell and how to do it manually in SharePoint Online. Let’s get started!

There is no direct way to copy or move users between SharePoint Online groups. But you can achieve it by following the below steps:

  1. Click on Settings gear >> Site Settings.
  2. Click on “People and Groups” under the “Users and Permissions” group.
  3. Select the Source group name from the left navigation >> Select All Users by ticking the checkbox in the header >> Click on “E-mail Users” from the “Actions” menu. This opens the default email client with all users of the group. Copy them! 
    sharepoint online move users from one group to another
  4. Navigate to the destination group in SharePoint Online site>> Click on “Add users and paste those copied emails. You can remove them from the source group if it’s “Move”.

The above method could be relatively simpler when you have to copy or move a few users between SharePoint groups. Wouldn’t it be better to use the scripted way to copy multiple users in bulk?

SharePoint Online: Move Users from One Group to Another using PowerShell

Here is how you can move users from one group to another in SharePoint Online:

#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$SourceGroupName = "Marketing Team"
$DestinationGroupName = "Marketing Managers"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get Members of the Source Group
$SourceGroup = Get-PnPGroup -Identity $SourceGroupName | Select-Object Users

#Add users to destination group
Foreach ($User in $SourceGroup.Users)
{
    #Frame User ID
    $UserID = "i:0#.f|membership|"+$User.Email
    #Add user to Group
    Add-PnPGroupMember -LoginName $UserID -Identity $DestinationGroupName

    #Remove user from source group
    Remove-PnPGroupMember -LoginName $UserID -Identity $SourceGroupName

    Write-host "User Moved :"$User.Email
}

You can comment out the “Remove-PnPGroupMember” (Line#20) to perform copy users between groups.

PowerShell to Move Users between Groups from One Site to Another

How about moving users between groups on different sites?

#Parameters
$SourceSiteURL = "https://crescent.sharepoint.com/sites/marketing"
$DestinationSiteURL = "https://crescent.sharepoint.com/sites/Purchase"
$SourceGroupName = "Marketing Members"
$DestinationGroupName = "Purchase Members"

Try {
    #Connect to the Source and Destination Sites
    $SourceSite = Connect-PnPOnline -Url $SourceSiteURL -Interactive -ReturnConnection
    $DestinationSite = Connect-PnPOnline -Url $DestinationSiteURL -Interactive -ReturnConnection

    #Get Members of the Source Group
    $SourceGroup = Get-PnPGroup -Connection $SourceSite -Identity $SourceGroupName | Select-Object Users
 
    #Add users to destination group
    Foreach ($User in $SourceGroup.Users)
    {
        #Resolve the User
        $ResolvedUser = Get-PnPUser -Connection $DestinationSite | Where-Object LoginName -eq $User.LoginName
        If($ResolvedUser -eq $null) {        
            $ResolvedUser = New-PnPUser -LoginName $User.LoginName -Connection $DestinationSite
        }

        #Add user to Group
        Add-PnPGroupMember -Connection $DestinationSite -LoginName $User.LoginName -Identity $DestinationGroupName
 
        #Remove user from source group
        Remove-PnPGroupMember -Connection $SourceSite -LoginName $User.LoginName  -Identity $SourceGroupName
 
        Write-host "User Moved :"$User.LoginName
    }
}
Catch {
    write-host -f Red "`tError:" $_.Exception.Message
}

Please note, If you have external users enabled for the source site, You must do so on the destination site as well (which is obvious, isn’t it?).

Wrapping up

In conclusion, copying users from one group to another in SharePoint Online is a simple and efficient process that can help organizations manage user access and permissions effectively. By following the steps outlined in this article, you can easily transfer users from one group to another in SharePoint Online and ensure that users have the appropriate access to resources.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

5 thoughts on “SharePoint Online: Copy/Move Users from One Group to Another

  • Good tips. One thing I don’t like about method #1 is the moved user is emailed a notice as if granted access. There needs to be a simple way (not Powershell) to move users in different groups with stealth.

    Reply
  • Could you explain how to to do this between two different sites?

    Reply
      • How can I export site permissions, users and groups from one site to another?

        Reply
  • Thx!!! You ‘re saved my day 🙂

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *