Recently, I got an urgent requirement to delete all the items from a SharePoint Online list. PowerShell is the best option for bulk deleting list items. In this tutorial, I will show you how to delete all items from a SharePoint list using PnP PowerShell and PowerShell.
I recommend using PnP PowerShell to delete items from the SharePoint list.
From all the examples, I will use the SharePoint Online list below. The list has a few items, as shown in the screenshot below.

Delete All Items from a SharePoint Online List using PnP PowerShell
PnP PowerShell provides efficient ways to work with SharePoint lists.
Here is the complete script to delete all items from a SharePoint list using PnP PowerShell.
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/MarketingTeam" -Interactive
$listName = "ProjectTasks"
# Get all items in the list
$items = Get-PnPListItem -List $listName
# Loop through and delete each item
foreach ($item in $items) {
Remove-PnPListItem -List $listName -Identity $item.Id -Force
}I executed the above script using VS code, and you can see in the screenshot below that all the SharePoint list items have been deleted.

While deleting SharePoint list items, you can also define the page size. Here is a complete script.
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/MarketingTeam" -Interactive
$listName = "ProjectTasks"
# Get all items in the list
$items = Get-PnPListItem -List $listName -PageSize 2000
# Loop through and delete each item
foreach ($item in $items) {
Remove-PnPListItem -List $listName -Identity $item.Id -Force
}
# Disconnect the session
Disconnect-PnPOnlineRead Import Data from Excel to SharePoint List using PnP PowerShell
Batch Delete SharePoint Large List Items using PnP PowerShell
If you are deleting all items from a large SharePoint list, the process can be a little slow. Batch deletion can significantly speed up the process. Using PnP PowerShell, it is easy to delete items in batch.
Here is the complete code.
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/MarketingTeam" -Interactive
$listName = "ProjectTasks"
# Get all items in the list
$items = Get-PnPListItem -List $listName
# Create a batch
$batch = New-PnPBatch
# Queue deletion of each item
foreach ($item in $items) {
Remove-PnPListItem -List $listName -Identity $item.Id -Batch $batch -Force
}
# Execute the batch
Invoke-PnPBatch -Batch $batchHere:
- The
Connect-PnPOnlinecmdlet with the-Interactiveparameter will prompt you to log in interactively. Get-PnPListItemretrieves the list items, and-PageSize 2000helps handle larger lists.Remove-PnPListItemis used to delete each item.
This is how to delete items from a large SharePoint Online list using PnP PowerShell with a batch.
Read Add More Than 5000 Items to a SharePoint Online List using PnP PowerShell
Delete All Items from a SharePoint List using PowerShell
In the first method, I will show you how to delete all items from a SharePoint Online list using PowerShell (SharePoint Online Management Shell). If you are new to this, you can download and install SharePoint Online Management Shell first.
Below is the complete PowerShell script to delete all items from the SharePoint list.
$siteUrl = "https://szg52.sharepoint.com/sites/MarketingTeam"
$listName = "ProjectTasks"
# Connect to the site
Connect-SPOService -Url $siteUrl
# Get the list
$list = Get-SPOList -Identity $listName
# Get all items in the list
$items = Get-SPOListItem -List $list
# Loop through and delete each item
foreach ($item in $items) {
Remove-SPOListItem -List $list -Identity $item.Id -Confirm:$false
}Once you execute the above script, all the items from the SharePoint list will be deleted.
In this tutorial, I have explained how to delete all items from a SharePoint Online list using PnP PowerShell and how to delete all items in batches from a large SharePoint list using PnP PowerShell.
If you still have questions, feel free to leave a comment below.
You may also like:
- Create, Read, Update, and Delete an Item from a SharePoint Online List using PnP PowerShell
- Delete and Recover a SharePoint Online Site Using PowerShell and PnP PowerShell
- Create a Site in SharePoint Online using PnP PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.