Delete all list items with powershell

Delete all list items with powershell



'Add-PSSnapin microsoft.sharepoint.powershell'

try{

$w = Get-SPWeb("http://sp14-dev-02")
$l = $w.GetList("/ArcPreservationHoldLibrary")
Write-Host $l.TypeFullName
$listItems = $l.Items;
$c = $listItems.Count

while ($c--)
{
    $item = $listItems.Delete($c)
    Write-Host $c
}

}catch{
      $ErrorMessage = $_.Exception.Message
      Write-Host $ErrorMessage
}
Posted on

Tags: SharePoint, Powershell, Delete List Item

Comments