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 site contents page, library's ribbon menu, SharePoint Designer, Content and structure tool, Explorer view, PowerShell but none of them helped!

You may not see "Delete this list" option if you don't have "Edit" or more access rights in SharePoint Online site! Also, in some of the 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

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.AllowDeletion = $True
    #Delete the Document Library (Send to Recycle bin)
    $Library.Recycle() | Out-Null
    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

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.