Build the batch operation command (note the query is limited to returning 2000 items at a time, and uses the ListItemCollectionPosition property to continue retrieving items in batches of 2000 until all the items have been queried. See the MSDN documentation on SPQuery.ListItemCollectionPosition Property for more info.)
$itemCount = 0; $listId = $list.ID; [System.Text.StringBuilder]$batchXml = New-Object "System.Text.StringBuilder"; $batchXml.Append(""); $command = [System.String]::Format( "{0}{1}Delete", $listId, "{0}" ); do { $listItems = $list.GetItems($query) $query.ListItemCollectionPosition = $listItems.ListItemCollectionPosition foreach ($item in $listItems) { if($item -ne $null){$batchXml.Append([System.String]::Format($command, $item.ID.ToString())) | Out-Null;} } } while ($query.ListItemCollectionPosition -ne $null) $batchXml.Append("");
Lastly, and most importantly, run the query!
$web = Get-Spweb http://inceweb/HKMarineDB; $web.ProcessBatchData($batchXml.ToString()) | Out-Null;
Richard Mueller edited Revision 3. Comment: Removed extra space in tag "SharePoint 2010"
Matthew Yarlett edited Revision 2. Comment: Fixed HTML tags at the end of the document
Matthew Yarlett edited Revision 1. Comment: Minor changes to wording.
The link to the blog at the end seems to be truncated (the title, the link itself works)