1

I have a list with 50 items. I don't want to change users' permissions to the list itself, but I do want to restrict their access to the 50 items created so far.

When I select all the items together, ITEM PERMISSIONS is greyed out in the toolbar, but I can do them one at a time.

Is there an way to change permissions for all items in a list at once?

Using either the ribbon, a workflow, PowerShell, or the Client Object Model?

Thanks.

1 Answer 1

1

For this purpose I suggest you to use powershell with something like this for-each item:

$web = Get-SPWeb -Identity "http://spserver.com"
$list = $web.Lists.TryGetList("MyList")
$group = "Makers"
$PermissionLevel = "Read"

if ($list -ne $null) {
  foreach ($item in $list.Items) { 
    if ($item.HasUniqueRoleAssignments -eq $False) {
      $item.BreakRoleInheritance($True)
    }
    else {
      if ($web.SiteGroups[$group] -ne $null) {
        $group = $web.SiteGroups[$group]
        $roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
        $roleDefinition = $web.RoleDefinitions[$PermissionLevel];
        $roleAssignment.RoleDefinitionBindings.Add($roleDefinition);
        $item.RoleAssignments.Add($roleAssignment);
      }
      else {
        Write-Host "Group is not valid."
      }
    }
  }
}
$web.Dispose()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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