Delete Items from a SharePoint List using PowerShell

Delete Items from a SharePoint List using PowerShell

In this post, we will discuss how we can delete list items using PowerShell in SharePoint 2013. The same PowerShell script we can use to delete list items in SharePoint 2016. We can write PowerShell script in Windows PowerShell ISE or you can use Visual studio code to write, debug and test PowerShell scripts.

Below is the PowerShell script. Open SharePoint 2013 Management Shell and run below PowerShell command.

I have a list name as “MyTestList99” which has below items. I want to delete all items using PowerShell.

Delete Items from a SharePoint List using PowerShell
Delete Items from a SharePoint List using PowerShell

$web = Get-SPweb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”

$list = $web.Lists[“MyTestList99”]

$items = $list.items

foreach ($item in $items)

{
$deleteitem=$list.GetItemById($item.ID)

$deleteitem.Delete()

}

After running above command, if you will refresh the list, you will not get any item in the list.

Delete Items from a SharePoint List using PowerShell
Delete Items from a SharePoint List using PowerShell

Read some SharePoint PowerShell tutorials:

Hope this will be helpful.


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →