Unable to delete the folder from SharePoint

Jadhav, Jyoti 0 Reputation points
2024-07-02T14:59:39.6766667+00:00

Hi,

We are unable to delete the folder from SharePoint even it is not having retention label or any check out file in it. Also the folder is not having any file in it.

The error coming as seen below

User's image

Could you please let us know why it is happening and solution to delete it ?

Regards,

Jyoti Jadhav

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,685 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 46,166 Reputation points Microsoft Vendor
    2024-07-03T09:49:32.9+00:00

    Here are tips to troubleshoot the issue:

    1.Check whether previously deleted files are still open in the browser and locally.

    2.Access the document library by using an owner account to check whether has draft files in the folder.

    3.In the document library, at the bottom left, click Return to Classic SharePoint, then try to delete the folder.

    4.In the classic document library, open the document library in the file explorer, then try to delete the folder.

    5.Use following PowerShell to delete the folder.

    Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking
       
    #Variables for Processing
    $SiteUrl = "https://tenant.sharepoint.com/sites/emilytest"
    $FolderURL="/sites/emilytest/Shared Documents/folder" #ServerRelativeURL
     
    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
        $Web = $Ctx.Web
     
        #Get the folder object from given URL
        $Folder=$web.GetFolderByServerRelativeUrl($FolderURL)
         
        #sharepoint online powershell delete folder in document library
        $Folder.DeleteObject()
        $Ctx.ExecuteQuery()
     
        Write-host "Folder deleted Successfully!" -ForegroundColor Green
    }
    Catch {
        write-host -f Red "Error deleting Folder!" $_.Exception.Message
    }
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.