1

I am searching for a powershell script to empty a SharePoint list, can someone give me that?

Or maybe there is an option in SharePoint / administration to empty a list with a click?

Eric Alexander
  • 43,293
  • 10
  • 53
  • 93
WWWWWWWWWP
  • 121
  • 3
  • 12

1 Answers1

2

As you wish to delete all the list items, the most efficient approach is deleting the list and recreating the list,

  • Go to List settings page of the list
  • Save the list as template without including the list contents
  • Go to list settings and delete the list
  • Recreate the list using the list template saved

If you wish to only empty the list without deleting it, refer below the powershell script for it,

$siteURL = "URL"
$site = new-object Microsoft.SharePoint.SPSite ( $siteURL )
$web = $site.OpenWeb()
$oList = $web.Lists["ListName"];
$collListItems = $oList.Items;
$count = $collListItems.Count -1;
for($intIndex = $count; $intIndex -ge 0; $intIndex--)
{
   $collListItems[$intIndex].Delete();
}
Nagarajan Muthukumar
  • 1,817
  • 10
  • 18