How to Copy Permissions from One List to Another in SharePoint Online using PowerShell?

Requirement: Copy permissions from one list to another in SharePoint Online.

PowerShell to Copy Permissions Between SharePoint Online Lists and Libraries

Have you ever needed to copy permissions from one list to another in SharePoint Online? Maybe you’ve set up a new list or library and need to quickly give users and groups the same permissions as an existing list. You may know there are no ways to clone permissions from an existing list to a new list in SharePoint Online without using 3rd party tools, as there isn’t any built-in way to do this. Well, not anymore! PowerShell can help make the process a lot easier. This blog post will show you how to copy permissions from one list to another in SharePoint Online using PowerShell.

Copy Permissions between List in SharePoint Online using PowerShell

Here is the PowerShell script to copy permissions from one list to another list in SharePoint Online:

#PowerShell Function to copy permissions between Lists in SharePoint
Function Copy-PnPListPermissions
         [Parameter(Mandatory=$True)] [string] $WebURL,
         [Parameter(Mandatory=$True)] [string] $SourceListName,
         [Parameter(Mandatory=$True)] [string] $TargetListName,
         [Parameter(Mandatory=$False)] [Bool] $AppendToExisting = $True
    Try {
        #Connect to PnP Online
        Connect-PnPOnline -Url $WebURL -Interactive

        #Get the Web
        $Web = Get-PnPweb
        $Ctx = Get-PnPContext

        #Get Source and Target Lists
        $SourceList = Get-PnPList $SourceListName  -Includes HasUniqueRoleAssignments -ThrowExceptionIfListNotFound
        $TargetList = Get-PnPList $TargetListName  -Includes HasUniqueRoleAssignments -ThrowExceptionIfListNotFound

        #if permissions are Inherited in Target List, Break the Inheritance
            If($AppendToExisting -eq $True)
                Set-PnPList -Identity $TargetList -BreakRoleInheritance -CopyRoleAssignments
                Set-PnPList -Identity $TargetList -BreakRoleInheritance
        Else #If the List has unique Permissions already
            If($AppendToExisting -eq $False)
                Set-PnPList -Identity $TargetList -ResetRoleInheritance
                Set-PnPList -Identity $TargetList -BreakRoleInheritance

        #Get all users and group permissions assigned to the source object
        $SourceRoleAssignments = Get-PnPProperty -ClientObject $SourceList -Property RoleAssignments
        #Copy Source list permissions to Destination List
        ForEach($RoleAssignment in $SourceRoleAssignments)
            #Get RoleDefinitions of the Role Assignment
            Get-PnPProperty -ClientObject $RoleAssignment -Property RoleDefinitionBindings, Member

            #Leave the Hidden permissions
            If($RoleAssignment.Member.IsHiddenInUI -eq $False)
                $SourcePermissions = $RoleAssignment.RoleDefinitionBindings | Where {$_.Name -notin("Limited Access")}
                $PermissionLevels = ($SourcePermissions | Select -ExpandProperty Name) -join "; "

                If($SourcePermissions -ne $null)
                    #Grant Source List's Permission Level to the Target List
                    $RoleDefBindings = New-Object Microsoft.SharePoint.Client.RoleDefinitionBindingCollection($Ctx)
                    ForEach($RoleDefinition in $SourcePermissions)
                    $Permissions = $TargetList.RoleAssignments.Add($RoleAssignment.Member,$RoleDefBindings)
                    Write-host "Copied '$($RoleAssignment.Member.Title)' with Permissions '$PermissionLevels'"
    Catch {
        write-host -f Red "Error Copying List Permissions!" $_.Exception.Message

#Set Parameters
$WebURL = ""
$SourceListName = "Documents"
$TargetListName = "Migration"

#Call the function to copy list permissions 
Copy-PnPListPermissions -WebURL $WebURL -SourceListName $SourceListName -TargetListName $TargetListName

This script appends to existing permissions of the target list by default. You can pass an optional parameter for -AppendToExisting with “$False” if you want to clear all existing permissions of the target list and copy permissions from the source list.

Here are my other posts on copying permissions in SharePoint Online:

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “How to Copy Permissions from One List to Another in SharePoint Online using PowerShell?

  • Can this be edited to copy permissions between different SP sites within the same tenant ?

  • Thanks, your method sounds good, and also I would to share, it is easy to do this job using migration tools like Gs Richcopy 360 and ShareGate.
    Good luck

    • Thank you , Gs Richcopy works fine


Leave a Reply

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