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
Post a Comment