How to delete list items in a SharePoint List using PowerShell?

In this Blog, I will you give the Power Shell script to delete all the list items in a specific list using PowerShell Commands. This is quite helpful especially if you are dealing with huge and bulk lists.

System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

$site = new-object Microsoft.SharePoint.SPSite(“http://mytest”)
$relweburl = ”/employeesite”
$web = $site.openweb($relweburl)

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

$listItems = $list.Items
$listItemsTotal = $listItems.Count

for ($item=$listItemsTotal-1;$item -ge 0; $item–)
{

Write-Host(“DELETED: ” )
$listItems[$item].Delete()
}
}

You can read my another Blog to add list items from a sharepoint list using PowerShell as well.

Happy SharePointing Folks!! Hope it helps!!

Leave a Reply

Your email address will not be published. Required fields are marked *