I am trying to delete list items, about 130K, from a large list on SharePoint Online using powershell CSOM, i am getting this error
"Exception calling "ExecuteQuery" with "0" argument(s): "The operation has timed out.""
this is my code
for ($i=$allItems.Count-1; $i-ge0; $i--)
{
$allItems[$i].DeleteObject()
#$clientContext.ExecuteQuery()
}
$clientContext.ExecuteQuery()
When i use the ExecuteQuery() outside the loop, i am getting this error. but it still deletes around 1K items each time i run the script.
But When i use the ExecuteQuery() inside the loop, it doesn't throw the error and the script completes execution, BUT it takes about 20 times the time taken to delete items when ExecuteQuery() used outside the loop
i also used RequestTimeout property
$clientContext.RequestTimeout = [System.Threading.Timeout]::Infinite ( or any value)
it doesn't seem to honor this property.
Could anyone please help me suggest a better way to delete such a large list ( the list is still being used, i can't delete the list)?
Thanks so much Maria Francis