Issue
Several hundred workflows have become stuck on 'Failed on Start (retrying)' and are causing the entire SharePoint environment to slow down.
Resolution
- Identify the lists where these workflows have become stuck.
- Using the script below, target the affected lists, and then use the script to terminate the stuck instances:
NOTE: Users must update the list name in the last line from 'WorkflowTestingList' to the name of the affected list. This script will terminate *ALL* workflows on said list with the status of 'Failed on Start (retrying)'
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinuefunction Cancel-SPWorkflow(){PARAM ([Parameter(ValueFromPipeline=$true)] [Microsoft.SharePoint.Workflow.SPWorkflow] $SPWorkflow)BEGIN { }END {}PROCESS { [Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($SPworkflow) }}function Get-SPWorkflow(){PARAM ([Parameter(ValueFromPipeline=$true)] [Microsoft.SharePoint.SPListItem] $SPListItem)BEGIN { }END {}PROCESS { $SPListItem.Workflows }}$(Get-SPWeb http://nsp-jb-sp13-1.nintexsupport.com/workflow).Lists["WorkflowTestingList"].Items | Get-SPWorkflow | where {[String]$_.StatusText -match [String]"Failed on Start (retrying)"} | Cancel-SPWorkflow
