SharePoint Online: “Delete this Document Library” is Missing

Problem: Cannot delete a SharePoint Online document library as “Delete this Document Library” option is missing in document library settings!

Tried deleting the library from the site contents page, library’s ribbon menu, SharePoint Designer, Content and structure tool, Explorer view, PowerShell but none of them helped!

Solution:

You may not see the “Delete this list” option if you don’t have “Edit” or more access rights on SharePoint Online site! Also, in some system libraries “Allow Deletion” flag is set to “FALSE” to prevent the library from accidental deletions. (E.g. in “Farm Templates”, “Style Library”, etc Delete this Document Library link is missing by default to prevent delete).

sharepoint online delete this document Library missing

How to enable delete in a SharePoint Online Document Library?

Use this PowerShell to enable Delete in a library by setting “Allow Deletion” flag to True!

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
#Set parameter values
$SiteURL="https://crescenttech.sharepoint.com/"
$LibraryName="AppAssets"

Try {
    #Get Credentials to connect
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
  
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials
 
    #Get the Document Library and set allow deletion flag
    $Library=$Ctx.Web.Lists.GetByTitle($LibraryName) 
    $Library.AllowDeletion = $True
    $Library.Update()
    $Ctx.ExecuteQuery()
             
    #Delete the Document Library (Send to Recycle bin)
    $Library.Recycle() | Out-Null
    $Ctx.ExecuteQuery()
 
    Write-Host "Document Library: '$LibraryName' has been Deleted Successfully!" -ForegroundColor Green  
}
Catch {
    write-host -f Red "Error Deleting Document Library!" $_.Exception.Message
}

This enabled deletion and deletes the document library. To delete a document library in SharePoint Online using PowerShell, refer my another post: SharePoint Online: PowerShell to Delete Document Library

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply