Remove All Items in List using MS PnP Powershell – SharePoint Online


I am sharing the below power shell snippet to help my fellows to remove all items in a list in the SharePoint online. Often we need to delete items at once using power shell or through JS code. PNP Power shell make it more easier to complete our task. (hats off)

Copy and paste the below code, it will loop through to a list and remove the item. Change the List name as yours.

Connect-PnPOnline –Url https://*********************

$items =Get-PnPListItem -List “ListName” -PageSize 1000

foreach ($item in $items)
{
try
{
Remove-PnPListItem -List “ListName” -Identity $item.Id -Force
}
catch
{
Write-Host “error”
}

} #for each end

To install PNP Power shell check the PnP PowerShell overview.

#Sharing is caring