Prevent Library Deletion In SharePoint 2016

Documents and Document Libraries form the heart of any SharePoint Implementation. Users with minimum Edit/Design permissions are eligible to delete the Lists. However, there can be cases of accidental list deletion. In the list settings page, clicking on ‘Delete this document library’ will delete the documents and library. In this blog, we will see how to prevent an accidental deletion of libraries, by hiding the delete option from list settings.

We can perform this action through Server-Side Object Model code as well. But, PowerShell counterpart is much easier to implement.

 Spin up SharePoint 2016 Management Shell as administrator.

Run the below command to prevent the list deletion from list settings. 

  1. $oWeb = Get-SPWeb "http://sharepoint2016"  
  2. $projectList = $oWeb.Lists["Projects"]  
  3. $projectList.AllowDeletion=$false  
  4. $projectList.Update()  

 

Going back to the list settings, we can see that the delete option has been removed.

Summary - Thus, we saw how to prevent the accidental deletion of SharePoint document library, by hiding the delete option from list settings.

Ebook Download
View all
Learn
View all