How to delete list items in SharePoint Online using Client Side Object Model with PowerShell?

Check out Best Alternative to InfoPath

In this post, we will discuss how we can delete list items in SharePoint online Office 365 using the Client Side Object Model (CSOM) with PowerShell. If you have more items to delete from SharePoint List, we can go for batch delete.

I would like to highlight programmatically when we delete list items, those are not moved to the Recycle Bin for the site.

Please find the below code.


Add-Type -Path “E:\PSDLL\Microsoft.SharePoint.Client.dll”

Add-Type -Path “E:\ PSDLL\Microsoft.SharePoint.Client.Runtime.dll”

$0 = $MyInvocation.MyCommand.Definition

$dp0 = [System.IO.Path]::GetDirectoryName($0)

$url = “”

$username = “”

$password = “*****”

$securePassword = ConvertTo-SecureString $password -AsPlainText -Force

#connect/authenticate to sharepoint online and get ClientContext object…

$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)

$clientContext.Credentials = $credentials



$web = $clientContext.Site.RootWeb






$query = New-Object Microsoft.SharePoint.Client.CamlQuery





if ($items.Count -gt 0)


for ($i = $items.Count-1; $i -ge 0; $i–)







Read some SharePoint csom articles:

Hope this will help.

You May Also like the Following SharePoint Online Tutorials:

About Sambita Rath

I have 9 years of exprience into SharePoint implementation, architecture, Administrator, development and Training.Designing Information Architecture in SharePoint 2007, 2010,2013 and Office 365.

View all posts by Sambita Rath →