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) }
Thanks.. This was very helpful
Link | September 20th, 2011 at 10:58 am
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)
Link | December 19th, 2011 at 7:55 am