SharePoint Online - Unable to delete some document libraries?

frob 4,216 Reputation points
2021-09-01T23:49:48.937+00:00

Hi there

I am a SharePoint Online Admin and site owner both.

I am unable to delete certain document libraries. I tried in the browser, and in PowerShell as well. In both cases, I get the same error.

The attempted operation is prohibited because it exceeds the list view threshold.

Please let me know how to delete those libraries.

Thank you.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,073 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
0 comments No comments
{count} votes

Accepted answer
  1. frob 4,216 Reputation points
    2021-09-02T18:01:04.22+00:00

    In case someone else may find this useful, I was able to resolve this with the following PowerShell command.

    Get-PnPListItem -List $List -Fields "ID" -PageSize 100 -ScriptBlock { Param($items) $items | Sort-Object -Descending | ForEach-Object{ $_.DeleteObject() } }
    

    Thank you.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Allen Xu_MSFT 13,796 Reputation points
    2021-09-02T07:07:43.557+00:00

    Hi @frob ,

    This is because of the resourced throttling threshold value of 5000 set on SharePoint Online. The list view threshold ensures that users are not performing expensive operations on the SharePoint Online environment. Unfortunately, we can’t change this threshold value as we do in SharePoint On-Premises.

    So, to mitigate this issue, we have to delete documents in batches firstly and then delete the library. To delete documents in batches, select all documents in the library via the below button and clcik Delete button in the ribbon.
    128585-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Limitless Technology 39,476 Reputation points
    2021-09-02T17:48:01.54+00:00

    Hello @frob

    There are several reasons why you may be unable to delete a file. Try each of these until you find one that resolves your issue.

    1. Ensure the item is not checked out by another user.
    2. Always make sure you have the appropriate permissions to delete the item or have a site collection administrator attempt to remove the item.
    3. Retention policies can cause this. You might have to either disable or exclude the respective hold policy that's causing the issue. After a retention policy or hold is removed, it may take up to 24 hours for the change to take effect. Ensure that there is not a retention policy set up on the item.
    4. The site might have exceeded its storage limit. Increase the site quota and delete the item.
    5. Administrators can use SharePoint Patterns and Practices (PnP), which contains a library of PowerShell commands that allows you to perform complex management actions such as force the deletion of items you cannot otherwise delete.

    You can store up to 30 million items or files in a list or library. Filtered views of large lists have a similar experience to other lists. However, when a list view shows more than 5000 items, you may run into a list view threshold error.

    In order to manage large lists and libraries do follow the below link,

    https://support.microsoft.com/en-us/office/manage-large-lists-and-libraries-b8588dae-9387-48c2-9248-c24122f07c59

    Hope this answers all your queries, if not please do repost back.
    If an Answer is helpful, please click "Accept Answer" and upvote it : )

    Regards,

    0 comments No comments