SharePoint 2013/2016: Deleting All List Item Using Powerhshell

$web = get-spweb "SiteCollectionURL";
$list = $web.lists | where {$_.title -eq "<You List Name>"}
Write-host "List $($list.title) has $($list.items.count) entries"
write-host "This will delete data, type YES to continue"
$retval = read-host
if ($retval -ne "YES")
{
write-host "exiting - you did not type yes" -foregroundcolor green
exit
}
write-host "continuing"
$items = $list.items
foreach ($item in $items)
{
Write-host " Say Goodbye to $($item.id)" -foregroundcolor red
$list.getitembyid($Item.id).Delete()
}
view raw gistfile1.txt hosted with ❤ by GitHub

Comments

Popular posts from this blog

SPFx: Develop using SharePoint Framework without Installing all the dependecies.

SharePoint Online: Elevated Permissions....with love

Powershell: Filling up an Existing Excel Sheet with data from SQL Server