kwizcom banner advertisement

SharePoint Online: Delete Drop Off Library using PowerShell

Requirement: Remove drop off library in SharePoint Online.

Site owner activated "Content Organizer" feature in a site which 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 "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 "Delete this Library" link, we've to use PowerShell to delete this library.

SharePoint Online Remove drop off library using PowerShell:
We can delete the Drop Off Library by setting: 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://crescenttech.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
}
In SharePoint On-premises also, you can remove any document library or list by setting: "AllowDeletion" to "True" as in my another article: How to Delete any Document Library or List in SharePoint using PowerShell
SharePoint Online: Delete Drop Off Library using PowerShell SharePoint Online: Delete Drop Off Library using PowerShell Reviewed by Salaudeen Rajack on June 19, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.