Remove the Retention Hold on the Sharepoint Library or Onedrive
Make sure you run this on the Sharepoint Site ( Onedrive ) – https://learn.microsoft.com/en-us/sharepoint/troubleshoot/sites/compliance-policy-blocking-site-deletion
https://aka.ms/PillarInvalidRetention
Make sure you do not put a / on the end
Bulk Delete would be using the above
#Config Variables
$SiteURL = "https://bottlehouse-my.sharepoint.com/personal/hello_bottlehouse_com_au"
$LibraryName ="Preservation Hold Library"
$ListName = "Preservation Hold Library"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Useweblogin
#Get the Library
$Library = Get-PnPList -Identity $LibraryName
#Check if document Library exist
If($Library -ne $Null)
{
#Set Allow Deletion Property to True
$Library.AllowDeletion = $True
$Library.Update()
Invoke-PnPQuery
#powershell to remove document library
Remove-PnPList -Identity $LibraryName -Force -recycle
Write-host -f Green "Preservation Hold Library Deleted Successfully!"
}
Else
{
Write-host -f Yellow "Could not find Preservation Hold Library!"
}
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Delete all files from the library
Get-PnPList -Identity $ListName | Get-PnPListItem -PageSize 100 -ScriptBlock { Param($items) Invoke-PnPQuery } | ForEach-Object { $_.Recycle() | Out-Null}