Here the quick solution to clean up/delete SharePoint list items that save a days lot if cleanup required. Manual efforts would take a lot so prefer to go with scripts;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# Enter the site URL instead http://sathiya.io $weburl = “http://sathiya.io” $site = new-object Microsoft.SharePoint.SPSite ($weburl) $web = $site.OpenWeb() Write-Host “The Web application is : “$web.Title # Enter name of the List below insted of ProjectList $oList = $web.Lists[“ProjectList”]; $collListItems = $oList.Items; $count = $collListItems.Count – 1 $itemCount = $contents.Count; $currentItem = 1; Write-Output -NoNewline “Are you sure you want to permanently delete the ‘$oList.ItemCount’ item from the list ‘$oList.Title’ (y/n)? “ -NoNewline; $con = Read-Host; if ($con -eq “y”) { for($intIndex = $count; $intIndex -gt -1; $intIndex—) { #Deleting the item from list “Deleting record: “ + $intIndex $collListItems.Delete($intIndex); } Write-Host $itemCount “item has been deleted from the list ‘”$oList.Title “‘…!” -ForegroundColor Yellow; } else { Write-Host “No changes are happened in the list'”$oList.Title “‘…!” -ForegroundColor Black -BackgroundColor Green; } #Close the connection $web.Dispose() |
Cheers…!