Delete all Items in SharePoint List Using PowerShell

Delete all Items in SharePoint List Using PowerShell

Manually deleting all items in a SharePoint list can be a time-consuming and tedious task, especially when dealing with large amounts of data. By leveraging the power of PowerShell, you can automate the process of deleting all items in a SharePoint list, saving time and effort.

In this guide, we will walk you through the steps to create a PowerShell script that can efficiently and reliably delete all items in a SharePoint list with just a few clicks. This solution will help you streamline your SharePoint management tasks and improve your overall productivity.

 

write-host “Type YES to continue”$retvalue = read-host
if ($retvalue -ne “YES”)
{
write-host “exiting” -foregroundcolor green
exit
}
write-host “continue”$web = get-spweb http://sharepointweburl:2015
$list = $web.lists | where {$_.title -eq “List Name”}
Write-host “List $($list.title) has $($list.items.count) entries”
$items = $list.items
foreach ($item in $items)
{
Write-host ”  Deleted: $($item.id)” -foregroundcolor red
$list.getitembyid($Item.id).Delete()
}

Related Article: