Delete all items in SharePoint List using PowerShell
While testing SharePoint solution with SPLists I often need empty list. I'd like to have analog for "Truncate" in SQL, but there's nothing for SharePoint.
So I wrote a short PowerShell script for deleting all items in SharePoint List. Here it is
# "Enter the site URL instead http://serverurl"
$SITEURL = "http://serverurl"
$site = new-object Microsoft.SharePoint.SPSite ( $SITEURL )
$web = $site.OpenWeb()
"Web is : " + $web.Title
# Enter name of the List below insted of LIST NAME
$oList = $web.Lists["LIST NAME"];
"List is :" + $oList.Title + " with item count " + $oList.ItemCount
$collListItems = $oList.Items;
$count = $collListItems.Count - 1
for($intIndex = $count; $intIndex -gt -1; $intIndex--)
{
"Deleting record: " + $intIndex
$collListItems.Delete($intIndex);
}
Using C# deleting like this - it must be from last to first element (Correct way to delete all SPListItems)

Login as another user in SharePoint 2019 on-premises site in Chrome
Set limited Wi-Fi connection within command line in Windows
A sticker problem with the fan in HP laptop