SharePoint Online: Delete Drop Off Library using PowerShell

Requirement: Remove drop off library in SharePoint Online.

The site owner activated the “Content Organizer” feature in a site that brought “Drop Off  Library” into the SharePoint Online site. Now, when he tried deleting this library by going to library settings, he could not find the “Delete this document library” link in the library’s settings! Deactivating the content organizer feature didn’t help. So, How to delete the drop off library from SharePoint Online?

delete drop off library in sharepoint online

As the drop off library doesn’t provide the “Delete this Library” link, we must use PowerShell to delete this library.

SharePoint Online Remove drop off library using PowerShell

The drop-off library automatically routes documents to their appropriate location on the site with a content organizer feature. Once the feature is deactivated, We can delete the Drop Off Library by setting: the AllowDeletion property. Here is the PowerShell script to delete the drop off library in SharePoint Online:

#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"
   
##Variables for Processing
$SiteUrl = "https://Crescent.sharepoint.com/DocCenter"

Try { 
    #Get Credentials to connect
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
  
    #Set up the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
    $Ctx.Credentials = $credentials
   
    #Get the Drop Off Library
    $Library = $Ctx.web.Lists.GetByTitle("Drop Off Library")

    #Set Allow Deletion Property
    $Library.AllowDeletion = $True
    $Library.Update()

    #Delete the Library
    $Library.DeleteObject()
    $Ctx.ExecuteQuery()

    Write-Host -f Green "Drop Off Library Deleted Successfully!"
}
Catch {
    write-host -f Red "Error Deleting Drop Off Library!" $_.Exception.Message
}

PnP PowerShell to Delete a Drop-OFF library in SharePoint Online

You can also use PnP PowerShell to delete the drop off library:

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Projects/"
$LibraryName="Drop Off Library"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
 
#Get the Library to Delete
$Library = Get-PnPList -Identity $LibraryName -ErrorAction SilentlyContinue
 
#Check if Library exists
If($Library)
{
    #Allow Deletion
    $Library.AllowDeletion = $True
    $Library.Update()
    Invoke-PnPQuery
 
    #delete library in sharepoint online powershell
    Remove-PnPList -Identity $LibraryName -Recycle -Force
    Write-host -f Green "Library '$LibraryName' Deleted Successfully!"
}
Else
{
    Write-host -f Yellow "Could not find Library '$LibraryName'"
}

In this article, we have discussed how to delete a drop-off library in SharePoint Online. By following the steps outlined in this guide, you can quickly and easily delete a drop-off library to reduce clutter in your SharePoint Online environment.

In SharePoint On-premises also, you can remove any document library or list by setting: “AllowDeletion” to “True” as in my other article: How to Delete any Document Library or List in SharePoint using PowerShell?

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

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