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.
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 "https://sharepoint.crescent.com/sites/operations"
#Get the list
$list = $web.Lists["AppConfig"]
#Make the list
$list.AllowDeletion = $false
$list.Update()
Result: SharePoint delete list missing!
In this way, we stop users from deleting SharePoint lists. If you notice, in some SharePoint lists & libraries (E.g. “Farm Templates” library), “Delete this List” or “Delete this Document Library” links are missing by default to prevent the delete option.
Revert the flag “AllowDeletion” to “True” programmatically if you must delete a list that doesn’t offer the “Delete this list” link. Once this flag set to false, we can’t delete it even programmatically! You will get a “This list cannot be deleted.” error if you try to delete it.