Cannot delete doc in SP online after removing retention label

Tanmoy Das 66 Reputation points
2022-11-01T06:59:48.267+00:00

Hi Friends,

In a library, I applied retention label to some documents. I was testing the behaviour. After removing the label still I cannot delete those files. Getting the below error

255906-image.png

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

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 43,331 Reputation points Microsoft Vendor
    2022-11-02T06:43:22.273+00:00

    @Tanmoy Das

    Please follow below tips to troubleshoot the issue.

    1.Make sure the file is not checked out to another user. And the file is not opened in your device or other devices.

    2.Go to Library settings -> Apply label to items in this list or library -> On the Apply Label, you can select "None" from the drop-down box and check the "Apply label to existing items in the library" check box -> Save.

    Then try to delete the file again.

    3.Try to delete file by using following PowerShell.

    #Config Variables  
    $SiteURL = "https://Crescent.sharepoint.com/sites/emilytest"  
    $FileRelativeURL ="/sites/emilytest/Shared Documents/test.xlsx"  
    
    #Get Credentials to connect  
    $Cred = Get-Credential  
    
    Try {  
        #Connect to PnP Online  
        Connect-PnPOnline -Url $SiteURL -Credentials $Cred  
    
        #Try to Get File  
        $File = Get-PnPFile -Url $FileRelativeURL -ErrorAction SilentlyContinue  
        If($File)  
        {  
            #Delete the File  
            Remove-PnPFile -ServerRelativeUrl $FileRelativeURL -Force  
            Write-Host -f Green "File $FileRelativeURL deleted successfully!"  
        }  
        Else  
        {  
            Write-Host -f Yellow "Could not Find File at $FileRelativeURL"  
        }  
    }  
    catch {  
        write-host "Error: $($_.Exception.Message)" -foregroundcolor Red  
    }  
    

    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.