1

I am using following Powershell script to break the folder permissions inside the Record Libraries:

    $webUrl = 'http://intranet'
    $web = Get-SPWeb $webUrl;
    $SPBaseTypeDocumentLibrary = [Microsoft.SharePoint.SPBaseType]::DocumentLibrary
    $lists = $web.GetListsOfType($SPBaseTypeDocumentLibrary);
    foreach ($list in $lists)
    {
    if ($list.BaseTemplate.ToString() -eq "1302")
    {
    $folders = $list.Folders
    foreach ($spFolder in $folders)
    {             
        # Add claims to folder
        $folderName = $spFolder.Name
        $spFolder.BreakRoleInheritance($false);
        $claimToken = "c:0-.t|clientcontracts|" + $folderName
        $claimUserDisplayName = "Claim User " + $folderName  
        $roleAssignment = New-Object microsoft.sharepoint.SPRoleAssignment($claimToken,"",$claimUserDisplayName,"")
        $roleAssignment.RoleDefinitionBindings.Add($web.RoleDefinitions["Read"]);      
        $spFolder.RoleAssignments.Add($roleAssignment);       
        $spFolder.Update();   
        }        
        }
       }

       $web.Dispose()

The issue is that the script is gets very sluggish. I have about 100 Libraries and each library contains 1000 folders. Is there any way to improve the performance of this script? How can we break permissions of folders in batches?

2

This really isnt a PowerShell issue. Instead it clearly stipulates why setting unique permissions (especially alot of different ACL's) on items/folders in a SharePoint list is not recommended, especially for large lists.

I would recommend rethinking the design...

@james-love also made a couple of posts on his blog on this issue

http://e-junkie-chronicles.blogspot.dk/2011/03/sharepoint-2010-performance-with-item.html

http://e-junkie-chronicles.blogspot.dk/2011/03/sharepoint-2010-performance-with-item_23.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.