Thursday, December 29, 2011

PowerShell to Delete a List in a Site

To delete a list in a site:Change -Identy URL "Site Collection URL"
Change ["List Name"]

Then copy and paste all below to SharePoint Management Shell (running as administrator).

$assignment = Start-SPAssignment
$web = Get-SPWeb -Identity "http://%3csite/ Collection URL>" -AssignmentCollection $assignment
$list = $web.lists["<List Name>"]
$list.AllowDeletion = $true
$list.Delete() #this will delete the list
Stop-SPAssignment $assignment