One-liners
PowerShell script that will identify all Workflow History lists in the farm:
$farm = Get-SPFarm; $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}; foreach ($websvc in $websvcs) { foreach ($webapp in $websvc.WebApplications) { foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { if ($list.BaseTemplate -eq [Microsoft.SharePoint.SPListTemplateType]::WorkflowHistory) { [string]::Format("{0} ({1}) - {2}", $list.Title, $list.ItemCount, $list.ParentWeb.Url) } } } } } }
If you want to limit the lists identified to lists that have more than 1,000,000 rows:
$farm = Get-SPFarm; $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}; foreach ($websvc in $websvcs) { foreach ($webapp in $websvc.WebApplications) { foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { if ($list.BaseTemplate -eq [Microsoft.SharePoint.SPListTemplateType]::WorkflowHistory -and $list.ItemCount -ge 1000000) { [string]::Format("{0} ({1}) - {2}", $list.Title, $list.ItemCount, $list.ParentWeb.Url) } } } } } }
If you want to further limit to a certain web application:
$webapp = Get-SPWebApplication "http://sp"; foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { if ($list.BaseTemplate -eq [Microsoft.SharePoint.SPListTemplateType]::WorkflowHistory -and $list.ItemCount -ge 1000000) { [string]::Format("{0} ({1}) - {2}", $list.Title, $list.ItemCount, $list.ParentWeb.Url) } } } }
Feedback
Let me know if this helps!
Recent Comments