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?