Is there a way to get a list of all suspended workflows in SharePoint 2013 using powershell? i have quite few workflows running in sharepoint 2013 farm and i need to get a list of all suspended instances
sharepoint 2013 migration to sharepoint online workflows are very different than 2010 workflows.
The $item.Workflows collection seems to only be associated with SP2010 workflows, for SP2013 workflows you must use WorkflowServicesManager and WorkflowInstanceService
# Workflow Services Manager
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
# Workflow Instance Service
$wfis=$wfm.GetWorkflowInstanceService()
# loop through all list items
foreach($item in $list.items)
{
# loop through all workflow instances
foreach($wfinstance in $wfis.EnumerateInstancesForListItem($list.id, $item.id))
{
# is the instance suspended?
if ($wfinstance.status -eq “Suspended”)
{
# terminate!
$wfis.TerminateWorkflow( $wfinstance )
}
}
}