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?

1

1 Answer 1

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();
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.