Delete all items from the list

Sviatoslav Bulash -

Use this script if you need to delete all items from list.

Replace URL with your root site url.

Replace LIST_NAME with list display name.

 

$Sc_URL = "http://URL/es/" $SPAssignment = Start-SPAssignment
$SPWeb = Get-SPWeb $sc_url -AssignmentCollection $spAssignment
$array = New-Object System.Collections.ArrayList
$array.Clear()
$n = 0
$k = 0
$list = $SPWeb.Lists["LIST_NAME"]
foreach ($el in $list.items)
{$array.Add($el)}
$n = $array.count -1
for ($k = $n; $k -ge 0; $k--)
{
$array[$k].delete()
}
$array.Clear()
Have more questions? Submit a request

Comments

Powered by Zendesk