Fixing the AllowDeletion flag on a SharePoint list or library

Today is the second time I ran into this issue, and I figure I better post it out there before I once again forget how to solve it…

I got a call from one of my customers saying that they didn’t have the option to delete a document library from Library Settings. Odd, as they had full control permissions for the site. When I looked (and I’m basically God when it comes to permissions), I didn’t have it either.

After some digging around, I found that there’s a setting called AllowDeletion that you can manipulate to keep someone from deleting a list or library. I’m still not entirely sure *how* that got get set to false in this case, but it was.

Following is a short PowerShell script you can use to fix that. The actual deletion of the library is commented out here, because I’d prefer just to set the flag and then delete it myself… less chance of something going wrong that way. 🙂

#DeleteUndeletableLibrary.ps1
#This allows you to delete a list or library where the AllowDeletion flag has been turned off...
#Load SharePoint PowerShell Snapin
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
 
$Web = Get-SPWeb "http://foo.com/website"
$List = $Web.Lists["LibraryName"] 
$List.AllowDeletion = $TRUE 
$List.Update() 
#$List.Delete() 
#$Web.Dispose()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s