2

I have a need to remove unique permissions on documents in a list, however, the list is over 5000 items so the following won't work, and its SharePoint Online so I can't change the threshold.

$ctx=New-Object Microsoft.SharePoint.Client.ClientContext("https://www.example.com/subSite/")

$password = ConvertTo-SecureString -string "MyPassword" -AsPlainText -Force

$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("admin@mytenant", $password)

$ll=$ctx.Web.Lists.GetByTitle("Company Docs")
  $ctx.Load($ll)
  $ctx.ExecuteQuery()
  $spQuery = New-Object Microsoft.SharePoint.Client.CamlQuery

  $spQuery.ViewXml ="<View Scope='Recursive' />";


  $itemki=$ll.GetItems($spQuery) 
  $ctx.Load($itemki)
  $ctx.ExecuteQuery()
  for($j=0;$j -lt $itemki.Count ;$j++)

  {
      $itemki[$j].ResetRoleInheritance()
      $ctx.ExecuteQuery()
  }

As an alternative, if I can specify a sub-folder I have a chance of getting this working.

Something like:

$spQuery.FolderServerRelativeUrl= "/SubSite/Company Docs/Folder1/"

I can't seem to get this to work though, any thoughts?

1 Answer 1

0

Try looking into SPQuery paging with CSOM:

https://social.technet.microsoft.com/wiki/contents/articles/18606.sharepoint-2013-paging-with-sharepoint-client-object-model.aspx Using:

var pageInfo = "Paged=TRUE&p_ID=<ID last of ListItem>;"
var position = new SP.ListItemCollectionPosition();
position.set_pagingInfo(pageInfo);
camlQuery.set_listItemCollectionPosition(position);

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.