Deleting all Lists with PowerShell

To delete all lists of a Web you can use this little PowerShell script.

$web = get-spweb http://sharepoint.contoso.com/
$lists = $web.Lists | Where-Object {$_.AllowDeletion -eq $true}
$lists | ForEach-Object {$_.Delete()}

The select on AllowDeletion ensures hereby that only lists will get deleted that are not relevant for the functionality of the SharePoint site.

Furthermore it is necessary to store the temporary collection of lists in a separate variable. Otherwise you will encounter an exception because you try to modify a collection while looping through it.

Thanks to Michael Windler who gave me that hint 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × one =