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.
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 $list.Update()Result: SharePoint 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.
You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.