SharePoint Online - Unable to delete some document libraries?

frob 4,216 Reputation points

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.

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

    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

    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.

    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

    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,

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


    0 comments No comments