Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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