Friday, June 27, 2014

Deleting a SharePoint List using PowerShell

I recently encountered an issue whereby a SharePoint List was restored to a site using a Granular Backup, however, the site could not be deleted from the User Interface.

Of course, I decided to try deleting it via PowerShell using the following script:
$siteUrl = "http://sp2013sp1"
$listTitle = "My List"
 
$web = Get-SPWeb $siteUrl
$list = $web.Lists[$listTitle]
$list.AllowDeletion = $true
$list.Update()
 
$list.Delete()
$web.Close()

As you can guess, the PowerShell script worked!

No comments:

Post a Comment