SharePoint Online: How to Disable “Delete this list”?

Requirement: Disable the “Delete” option in a SharePoint Online List or Document Library.

How to Disable the Delete option for a List or Library in SharePoint Online?

We have a requirement to disable any accidental deletes on specific SharePoint Online lists and document libraries that are provisioned as part of a custom application. If you have noticed, 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. So, How do we disable delete options?

Well, if you want to disable the delete list option from list settings in SharePoint (and in other places, too!), you can set the “AllowDeletion” property of the List or Library to “False”. Once this is set, delete options go hidden!

sharepoint online disable delete this list

PowerShell to Disable Delete in SharePoint Online List

Let’s turn the “Allow Delete” flag to “False” to prevent deletion.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

#Set Parameters for Site URL and List Name
$SiteURL= ""
$ListName= "config"
#Setup Credentials to connect
$Cred = Get-Credential
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
    #Get the List
    #disable delete in sharepoint online list
    $List.AllowDeletion = $False
    Write-host -f Green "List Settings Updated Successfully!"
Catch {
    write-host -f Red "Error Updating List Settings!" $_.Exception.Message

This script hides delete options from the given list in places such as from list settings. Similarly, we can disable the delete option for SharePoint Online document libraries as well. Let’s use PnP PowerShell this time:

#Set Parameters
$SiteURL = ""
$ListName = "Inventory"

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

#Disable delete in sharepoint online document library
$List = Get-PnPList -Identity $ListName -Includes AllowDeletion
$List.AllowDeletion = $False

SharePoint Online Can’t Delete List?
Once the “AllowDeletion” flag is set to false, we can’t delete the list through web UI or PowerShell until we revert the flag to “True”. You will get a “This list cannot be deleted.” error if you try to delete it. If you must delete a list that doesn’t provide a delete link, use: How to Delete a List in SharePoint Online using PowerShell?

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *