Disable Delete List Option in SharePoint

What? We've a SharePoint list provisioned to store & retrieve custom application settings in a SharePoint site. Its critical to prevent this list from any accidental deletion, so we want to disable delete list option from list settings in SharePoint.

How? We can disable "Delete this list" link in SharePoint by setting the List or Library's AllowDeletion Property to "False". Once set, delete option will go hidden.
SharePoint list hide delete option
Disable "Delete This List" in SharePoint list
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the web where the particular list lives
$web = Get-SPWeb "http://sharepoint.crescent.com/sites/operations"
#Get the list
$list = $web.Lists["AppConfig"]
#Make the list 
$list.AllowDeletion = $false
Result: SharePoint delete list missing! sharepoint 2010 delete list missing
By this way, we stop users from deleting SharePoint lists. If you notice, in some of the SharePoint lists & libraries (E.g. "Farm Templates" library), "Delete this List" or "Delete this Document Library" links are missing by default to prevent delete option.

Revert the flag "AllowDeletion" to "True" programmatically, if you must delete a list that doesn't offer "Delete this list" link. Once this flag set to false, we can't delete it even programmatically! you will get "This list cannot be deleted." error if you try to delete it.

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.