Delete all SharePoint list items with PowerShell

Did you ever wanted to quickly delete all items from a SharePoint list without having to run into complex scenarios?
This can be simply achieved using PnP Powershell (obviously!). And it fits in a single line!

If you are looking for options to delete documents from SharePoint document libraries, maybe this post can help.

Delete SharePoint list items

Connect to the site using Connect-PnPOnline and then run:

Get-PnPList -Identity Lists/MyList | Get-PnPListItem -PageSize 100 -ScriptBlock { Param($items) 
$items.Context.ExecuteQuery() } | % {$_.DeleteObject()}

5 thoughts on “Delete all SharePoint list items with PowerShell

  1. Hello, Joel
    Hope you are doing well.

    And how about doing a Filter on $Items before a deleting action ??

    Warm regards.

  2. Hi Joel,

    I have the same problem and at first came to the same solution. But then I thought:
    “$_.DeleteObject()” runs for each item… Is there a way to run “delete” on the server side in a batches?
    So i tried:
    Get-PnPListItem -List $list -Fields “ID” -PageSize 100 -ScriptBlock { Param($items) $items | Sort-Object -Descending | ForEach-Object{ $_.DeleteObject() } }
    and it worked. Thougts?

  3. Hi Vladilen,

    That looks fine to me and may be much better in terms of performance. Have you tried to delete 1000+ items to ensure that it does not time out? If not, that’s great and thanks for sharing here

Leave a Reply