Deleting Share Point list Items using powershell.


Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
try
{  
   $web = Get-SPWeb "http:/Testurl/sites/Feedback/"   
$list = $web.Lists["Survey"]
  
$caml='<Where><Eq><FieldRef Name="Month" /><Value Type="Text">June</Value></Eq></Where>'

$query=new-object Microsoft.SharePoint.SPQuery
$query.Query=$caml
$col=$list.GetItems($query)
Write-Host $col.Count
$col | % {$list.GetItemById($_.Id).Delete()}
$web.Dispose()
}
catch
{
write-host $_.exception
}


Hope...
This code will help you...

Comments

Popular posts from this blog

SharePoint 2013 Keyword Query (KQL) Content Class Property Restrictions

Hide Save button in New and Edit form in SharePoint 2013 list

Filtering the Sharepoint List Taxonomy Column using Rest API