SharePoint Online: Move Users from One Group to Another

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

How to Move Users Between SharePoint Online Groups?
Well, there is no direct way to copy or move users between SharePoint Online groups. But you can achieve it by following below steps:
  • Click on Settings gear >> Site Settings
  • Click on "People and Groups" under "Users and Permissions" group
  • Select the Source group name from left navigation >> Select All Users by ticking the checkbox in the header >> Click on "E-mail Users" from "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
  • Navigate to the destination group in SharePoint Online site>> Click on "Add users and paste those copied Email.
The above method could be relatively simpler when you have to copy or move 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 -UseWebLogin

#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-PnPUserToGroup -LoginName $UserID -Identity $DestinationGroupName

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

    Write-host "User Moved :"$User.Email
}
You can comment the "Remove-PnPUserFromGroup" (Line#20) to perform copy users between groups.
SharePoint Online: Move Users from One Group to Another SharePoint Online: Move Users from One Group to Another Reviewed by Salaudeen Rajack on February 18, 2019 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.