Click here to Skip to main content
12,763,466 members (33,123 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 7 Nov 2013

Easiest Way of Cancelling All SharePoint Workflows in Progress

, 7 Nov 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
The easiest way to cancel all SharePoint workflows in progress

Do you have a really big list in SharePoint and have a workflow attached to it? Had you encountered an issue where this workflow suddenly stopped and left a good number of Workflows in progress?

Workflow Settings

Have you ever wondered where you find these workflows in progress? Going to each list one by one will be OK if you have 10 items on your SharePoint List but if you have 1000, that can be a daunting task cancelling them all by going to each list item. Well, things can be easier by using SharePoint Powershell where you can iterate to all list items that have workflows attached to them and cancel them programmatically if they confirm to a certain condition, like when they are not “Completed” or “Suspended”.

I had the same issue last week and I had to stop all of them and this is how I did it in Powershell.

#Your SharePoint Site URL
$web = Get-SPWeb "";
$web.AllowUnsafeUpdates = $true;    

#Your List Name
$list = $web.Lists["YourListName"];
$count = 0

#Loop through all Items in List then loop through all Workflows on each List Items.         
foreach ($listItem in $list.Items) 
	foreach ($workflow in $listItem.Workflows) 
		#Disregard Completed Workflows 
		if(($listItem.Workflows | where 
		{$_.InternalState -ne "Completed"}) -ne $null)
			#Cancel Workflows        
			write-output "Workflow cancelled for : 
					" $listItem.Title;  

You can also change the condition based on what your requirements are. For a full list of what’s available, please check it here.

Filed under: CodeProject, Programming, Tips
Tagged: Powershell, Sharepoint 2013, Sharepoint Foundation 2013


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Raymund Macaalay
Technical Lead
New Zealand New Zealand

You may also be interested in...

Comments and Discussions

QuestionBetter options - script Pin
322222221-Apr-14 1:15
member322222221-Apr-14 1:15 
SuggestionA more efficient variation Pin
Paul Ryan6-Jan-14 1:20
memberPaul Ryan6-Jan-14 1:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 7 Nov 2013
Article Copyright 2013 by Raymund Macaalay
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid