Delete all sharepoint list item using powershell

  •  
  •  
  •  
  •  
  •  
  •  

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

Leave a Reply

Your email address will not be published.

one × 1 =