Deleting a SharePoint List using Powershell

August 24, 2011

When I’m doing development tasks, there are times I need to quickly create and delete SharePoint content. Lists are one of those. Documenting a few different ways to delete a SharePoint 2010 list using Powershell.

Two lines:

$w = Get-SPWeb "http://sps2010"
$w.Lists.Delete([System.Guid]$w.Lists["My Custom List"].ID)

One line:

Get-SPWeb "http://sps2010" | Where-Object { $_.Lists.Delete([System.Guid]$_.Lists["My Custom List"].ID) }

or

Get-SPWeb "http://sps2010" | % { $_.Lists.Delete([System.Guid]$_.Lists["My Custom List"].ID) }

2 Comments to "Deleting a SharePoint List using Powershell"

  1. Hemant wrote:

    Thanks.. This was very helpful

  2. Pedro wrote:

    This is good. But I have some event handlers on my lists and don’t want to delete them. Do you know a similar two lines to delete ALL a list’s items (not the list itself)

Leave Your Comment

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org