I'm banging my head against a wall trying to get this final piece written for an automatic SharePoint Online site collection script. The final piece is creating a list within the site collection (which I did), break inheritance on said list (which I did) and then remove all permissions from list (which I'm struggling with).

Look at the attached picture below. I don't need much explanation as I'm comfortable with PowerShell and CSOM, if someone has done this before I would appreciate a pointer.

I want to remove all of the permissions you see below, leaving the "1007 Owners" and "BTS 1007 Access Manager". All of the rest should be removed. Everything I've tried hasn't worked.

enter image description here

2 Answers 2


BreakRoleInheritance has two params. Just use false and true for copyroleassignments and clearsubscopes respectively then add the groups you want:

$group = $ctx.Web.EnsureUser($group)
$roleDef = $web.RoleDefinitions.GetByName($role)
$roleBinding = New-Object Microsoft.SharePoint.Client.RoleDefinitionBindingCollection($ctx)
$ctx.Load($Web.RoleAssignments.Add($group, $roleBinding))
  • Thank you @Bunzab. This did it. For future people reading this, I needed to change: Line 2: $group = $ctx.Web.SiteGroups.GetByName($groupName) - was looking for a SP group permission, not a user Line 8: $ctx.Load($list.RoleAssignments.Add($group, $roleBinding)) - To populate the permissions on the list, not on the entire site collection. And of course populate the variables $groupName, $role and $list - $list = $ctx.Web.Lists.GetByTitle($ListTitle) Jul 6, 2016 at 23:10

Please check the following code

$web=Get-SPWeb http://site url
$list = $web.Lists["list/library name"]
[Microsoft.SharePoint.SPRoleAssignmentCollection] $spRoleAssignments=$list.RoleAssignments
for([int] $a=$spRoleAssignments.Count-1; $a -ge 0;$a--)
   if($spRoleAssignments[$a].Member.Name -eq "groupName")
  • The question states SharePoint Online, this is PowerShell only executing from the server itself Jul 6, 2016 at 8:53
  • Yes, that is for sharepoint on premise, SP online is pretty much all CSOM only. Jul 6, 2016 at 20:14

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.