Copy List Permissions in SharePoint using PowerShell

Ever wanted to clone permissions between SharePoint lists or Libraries? Well, Here is the nifty PowerShell script to copy permissions between SharePoint lists:

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

#PowerShell Function to copy permissions between Lists in SharePoint
Function Copy-ListPermissions()
{
 param(
     $WebURL,
     $SourceListName,
     $TargetListName
 )
 #Get the Web
 $Web = Get-SPweb $WebURL

 #Get Source and Target Lists
 $SourceList = $Web.lists[$SourceListName]
 $TargetList = $Web.lists[$TargetListName]

 #if permissions are Inherited in Source, apply it in Target list 
  if($SourceList.Permissions.Inherited)
   {
      $TargetList.ResetRoleInheritance()
   }
  else #Copy permissions from Source to Target List
  {
     #Reset the Inheritence in Target List
     $TargetList.BreakRoleInheritance($false)

     #Copy Source list permissions to Destination List
     $SourceList.RoleAssignments | foreach-object {
     $targetList.RoleAssignments.Add($_)
      }
  }
 $TargetList.Update()
}
#Call the function to copy list permissions 
Copy-ListPermissions "https://sharepoint.crescent.com/sites/operations/us" "Documents" "Invoice"

This script copies all users and groups from the source list to the target list. Any custom permissions already applied on the target list will be lost! The above method can be used to copy permissions between SharePoint list items and sites.

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!

2 thoughts on “Copy List Permissions in SharePoint using PowerShell

  • where do we input site address, source list name, and destination list name?

    Reply
    • Just pass them as parameters to “Copy-ListPermissions” function! As in Line#36

      Reply

Leave a Reply

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