Quick Powershell to delete all items in my Sharepoint list
A quick post with a simple script I gathered a while back that comes in handy for data cleansing before releasing a site:
– how to delete the 100s of items in my list without doing it from the web interface (limited to the maximum displayed in a view)
Use the #powershell script below.
Warning: do this at your own risk, don’t get the wrong site/list or you will regret it
Save this into a DeleteAll.ps1 file
replace “http://SharepointSite” by your site and “ListName2 by the list name where to delete all items.
and run .\DeleteAll.ps1 from Sharepoit PowerShell cmd prompt.
<strong> </strong> # script starts here…</div> <div>[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”) | out-null $oContentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService; [Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.WebApplications; $siteUrl = “http://SharepointSite” $webName = “” $spSite = new-object Microsoft.SharePoint.SPSite($siteurl) $spWeb = $spSite.OpenWeb($webName) $spList = $spWeb.Lists["List Name"] foreach ($item in $spList.items) { $deaditem=$splist.GetItemById($item.ID) $deaditem.Delete() }</div> <div>
via François on Sharepoint http://sharepointfrancois.wordpress.com/2012/10/31/quick-powershell-to-delete-all-items-in-my-sharepoint-list/
French native Sharepoint Consultant living in London. A crossway between a designer, developer and system architect. Prefers stretching the limit of out-of-the-box features rather than breaking them into code. When not working with Microsoft Sharepoint François is often found on Web2.0 News sites and related social networking tools.
This article has been cross posted from sharepointfrancois.wordpress.com/ (original article) |
Categories: Work
François Souyri, SharePoint
Comments (0)
Trackbacks (0)
Leave a comment
Trackback