Requirement: Copy 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 Script to copy Group Memberships from One user to another:
If you want to clone a particular user's permissions, use this PowerShell script: PowerShell to Copy Permissions in SharePoint
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 Script to copy Group Memberships from One user to another:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinueAlternatively, to add a user to SharePoint group, you can use Set-SPUser cmdlet
#Configuration Parameters
$SiteURL="http://intranet.crescent.com"
$SourceUserID="i:0#.w|Crescent\Salaudeen"
$TargetUserID="Crescent\Opera"
#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
$Group.AddUser($TargetUser)
}
Set-SPUser -Identity $TargetUser -Web $SiteURL -Group $GroupNameHowever, 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