Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > How to delete a large list in SharePoint 2010
March 31
How to delete a large list in SharePoint 2010

As is often the case, my PowerShell boundaries were expanded because of a question from a coworker. This week Laura had a document library that had over 7000 files and she needed to delete it. Unfortunately it had blown long past the large list throttling limit. When she tried to delete it in the interface she was greeted with this very unfriendly page:

SharePoint 2010 3-30-2011 9.54.27 PM

 

There are a few ways to deal with that, but she asked for a PowerShell way and who was I to say no? She could have gone into Central Admin and tweaked the throttling settings. She could have also logged into the site collection as the farm account. SharePoint will let you delete it that way too. But she wanted PowerShell, so by god I gave her PowerShell.

But first, let’s reproduce the large list, using PowerShell of course. Use the following PowerShell to create a list and add column to it:

$web = Get-SPWeb http://sharepoint/sites/team
$lists = $web.Lists
$lists.add("Gordo","Mucho Grande", "GenericList")
$custom = $lists["Gordo"]
$custom.Fields.Add("Number","Text",0)

Substitute the URL for one on your farm. After the list is created, use the following PowerShell to create a few thousand items.

for ($i=1; $i -le 7010; $i++)
{
$item = $custom.items.add()
$item["Title"] = "Item Title" + $i
$item["Number"] = "42"
$item.update()
}

Now that you have the list, log in as a site collection administrator that is NOT the farm account and try to delete the list. You should get the same error above. PowerShell to the rescue! I hope you’re sitting down, here’s how to delete that pesky large list.

$web = Get-SPWeb http://sharepoint/sites/team
$custom = $web.lists["Gordo"]
$custom.Delete()

Blammo! Large list de-leted! You can download all the glorious PowerShell here.

Thanks to Laura for expanding my horizons. Smile

tk

Comments

Thanks

Look at you making the jump over the development side :) Thanks for this post Todd, very useful.

- Nik Charlebois
 on 4/1/2011 9:27 AM

Re: Thanks

Nik,
I don't know why you'd say such a mean thing.

tk
Todd O. KlindtNo presence information on 4/1/2011 2:10 PM

Re: How to delete a large list in SharePoint 2010

do you have to log on as a farm account to run this powershell script?  wonder if it is becuase of powershell or just becuase of the credential doing the deletion operations?
 on 4/2/2011 8:58 PM

Re: How to delete a large list in SharePoint 2010

You don't have to be the Farm Account to do this, but you must be logged in as a SharePoint administrator account. See this blog post for what that account consists of, http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=259

tk
Todd O. KlindtNo presence information on 4/6/2011 8:11 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person

Twitter


Want a message when I reply to your comment? Put your Twitter handle here.

Attachments

 

 SysKit