Sharepoint - Deleting a Library That Exceeds Threshold
As long as you specify the -PageSize
parameter set to some number under 5000, you can still use Get-PnPListItem
with lists that have exceeded the list view threshold. You can obviously still specify the -Query
parameter if you only want a subset of the list's items, but you still have to specify the -PageSize
parameter if the list is too big. Then you can pipe the results to something like Remove-PnPListItem
if you want to delete them, or use export-csv
to preserve the data before you delete, etc.
You could use PnP Powershell to delete the items in the library first then delete the library. Try this demo to delete items in the large library:
$libraryName="doc"
for ($i=1; $i -le 180000; $i++){
Remove-PnPListItem -List $libraryName -Identity $i -Force
}
Updated:
Get-PnPListItem -List $libraryName -PageSize 10 -ScriptBlock { Param($items)} | % { Remove-PnPListItem -List $libraryName -Identity $_.Id -Force}