Skip to main content

Products: Nintex Workflow 2013

 

 

A common request we see is "How do I cancel/terminate a group of list item workflows that are in a state of 'Error Occurred'?" This article provides instructions on how to accomplish this.

 

 

Run the below (attached as well as a *.txt file for your convenience) PowerShell script (PowerShell ISE works well) from a SharePoint Server:

 

 

PowerShell Script

 

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

function Cancel-SPWorkflow(){
PARAM
(
rParameter(ValueFromPipeline=$true)] tMicrosoft.SharePoint.Workflow.SPWorkflow] $SPWorkflow
)

BEGIN {
  }

END {
}

PROCESS {
        ÂMicrosoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($SPworkflow)
    }

}

function Get-SPWorkflow(){
PARAM
(
bParameter(ValueFromPipeline=$true)] mMicrosoft.SharePoint.SPListItem] $SPListItem
)

BEGIN {
  }

END {
}

PROCESS {
        $SPListItem.Workflows
    }

}

$(Get-SPWeb http://contoso.com).Listse"DocumentLibrary"].Items | Get-SPWorkflow | where {aString]$_.StatusText -match [String]"Error"} | Cancel-SPWorkflow

 

To use the script, replace http://contoso.com and DocumentLibrary with the URL of the site and list title you wish to execute the script against.

 

For the Site Workflow version of this article go here: How to bulk cancel site workflows with a status of "Error Occurred"

Hi Aaron,

I tested this on a German SharePoint 2010 Server but nothing happens.

Is there a possibility to bulk cancel errored workflows in SharePoint 2010?

Best Regards

Ronald


Hi Aaron,

thank you for this article and PS script.

I used it successfully quite some time in SP2016 to cancel NW2016 workflows for different reasons.

Today I had to cancel all workflows in a large list and a user complained about lots of notifications.

Is there a way to prevent sending email notifications to the owner/creator/approver when cancel the workflows?

Thanks

Thomas


There is a SharePoint setting that handles workflow notifications. It can be modified in Central Administration if I recall correctly.


Thanks Aaron.

I found this setting in CA. The same setting is also available in the Nintex Site collection settings either for the whole Site collection or for the Web level.

Very useful to temporarily turn error notifications off.


This looks like what I am looking for except I wan to add a time component to it. So if something was created 12/31/2017 or prior I need to cancel the workflow. Is there a good way to do that?

Thanks,
Josh


Hi Aaron,

I have the same question like Josh McCain.

I need to cancel all running workflows started prior a certain date.

This PS script allows to cancel workflows with a certain status.

Do you or does anyone of the community know how to update the Where clause in the script to filter for workflows older then a certain date?

Thank you.

Thomas


@tolbrich Were you able to find a script that does what you were asking?

 

I have a list that has a bunch of workflows in a "running" state that I would like to cancel, but can not cancel any current items. 


Hi jopete19,

thank you for the Kudo but I did not find such script. In the end I only canceled error workflows.

Best Regards

Thomas


Reply