SharePoint Online: Clone User Group Memberships using PowerShell

Requirement: Clone a user’s group permissions to another user in a SharePoint Online Site.

PowerShell to Clone User Group Memberships in SharePoint Online

PowerShell to Clone User’s Group Memberships in SharePoint Online:

It’s a common real-world scenario that when someone leaves the organization and somebody else takes that role they want the same permissions! While the requirement sounds simple, it’s really cumbersome to achieve it through the web user interface. Basically, you have to go to each group where the source user is a member of, and add the target user to it. Here is how we can automate this task by using PowerShell:

#Function to copy group memberships from one user to another
Function Clone-SPOUserGroupPermission($SiteURL, $SourceUserID, $TargetUserID)
    Try {
        #Get the Site collection
        $Site = Get-SPOSite $SiteURL 
        #Get the Source user
        $SourceUser = Get-SPOUser -Site $Site -LoginName $SourceUserID

        #Get All groups of the source User
        $UserGroups = $SourceUser.Groups
        If($UserGroups.Count -gt 0)
            Write-host -f Yellow "Found the User Member of $($UserGroups.Count) Group(s)..."

            #Loop through each group of the source user and add target user to that group
            ForEach ($Group in $UserGroups)
                #Add Target User to the Group
                Add-SPOUser -Site $Site -LoginName $TargetUserID -Group $Group | out-null    
                Write-Host -f Green "Added $TargetUserID to Group '$Group'"
    Catch {
        Write-host $_.Exception.Message -f Red

#SharePoint Online Admin Center URL
$AdminCenterURL = ""
$SiteURL = ""
$SourceUserID ="[email protected]"
$TargetUserID ="[email protected]"

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)

#Call the Function
Clone-SPOUserGroupPermission -SiteURL $SiteURL -SourceUserID $SourceUserID -TargetUserID $TargetUserID 

You can also use the “Get-SPOSite” cmdlet to get all site collections and call the function to copy the user’s group memberships to another user.

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!

One thought on “SharePoint Online: Clone User Group Memberships using PowerShell

  • April 14, 2020 at 4:12 PM

    Hi Sir,

    Is there any way to clone user on entire tenant level?



Leave a Reply