In experimenting with the upper limit thresholds of just how many items you can create in a list, I ran into a little problem in that the web UI went mental and would cause IE to crash (this was with 21,000 list items). Trying to access the files via Webdav was equally non-workable. I needed to get rid of these list items to even be able to roll back the crazy test.

PowerShell to the rescue. Just replace the “http://serverurl” and “ENTER LIST NAME HERE” values with your web URL and List Name.

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

# "Enter your site URL here"
$SITEURL = "http://serverurl"

$site = new-object Microsoft.SharePoint.SPSite ( $SITEURL )
$web = $site.OpenWeb()
"Web is : " + $web.Title

# Enter name of the List below
$oList = $web.Lists["ENTER LIST NAME HERE"];

"List is :" + $oList.Title + " with item count " + $oList.ItemCount

$collListItems = $oList.Items;
$count = $collListItems.Count - 1

for($intIndex = $count; $intIndex -gt -1; $intIndex--)
{
        "Deleting : " + $intIndex
        $collListItems.Delete($intIndex);
} 

Note that the assembly references at the top refer to SharePoint 2007 assemblies – not to worry, settings in the out-of-the-box SP 2010 Web.config will automagically bump up the references to the current SharePoint 2010 versions – there’s no burning need to go around adjusting assembly references if you come across PoweShell examples like this.