I am trying to delete items in my sharepoint list something like this:
foreach ($li in $listitems)
{
if ($li.id -eq 100 )
{
$li.Delete();
}
}
}
But this error comes up:
Collection was modified; enumeration operation may not execute.
How can I delete listitems in a foreach loop?
https://sharepoint.stackexchange.com/questions/38115/how-to-delete-all-items-in-a-list-using-powershell
– Shane Gib. Apr 16 '18 at 13:42