Copy Group Membership Permissions of a User in SharePoint using PowerShell

Requirement: Copy the SharePoint Group Memberships of one user to another user.

Solution: You can copy group memberships of one user to another user to have identical SharePoint Permissions for a SharePoint Site. Here is the PowerShell Script:

powershell to copy group membership permissions in sharepoint

PowerShell Script to Copy Group Memberships from one user to another:

Do you want to copy group memberships from one user to another? Here is the PowerShell to do that!

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters


#Get the web
$web  = Get-SPWeb $SiteURL

#Get All group membershipss of the source user
$UserGroups = Get-SPUser $SourceUserID -web $SiteURL | Select -ExpandProperty Groups

#Get the Target User
$TargetUser = $web.EnsureUser($TargetUserID) 

#Add target user to each group
Foreach($GroupName in $UserGroups)
    Write-Host "Adding User to the Group:"$GroupName
    #Get the Group
    $Group = $Web.SiteGroups[$GroupName]
    #Add User to Group

Alternatively, to add a user to the SharePoint group, you can use the Set-SPUser cmdlet

Set-SPUser -Identity $TargetUser -Web $SiteURL -Group $GroupName

However, if the group doesn’t has access to the site, you’ll get an error message: “The specified group does not exist.”

If you want to clone a particular user’s permissions, use this PowerShell script:  PowerShell to Copy Permissions in SharePoint

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

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