Monday, February 1, 2016

SharePoint 2013 TIP: cancel multiple workflows using PowerShell

When I update the development farm content from the production farm, there will usually be a number of list workflows still running that are being brought over from production.  It makes no sense to have these workflows still running on the development farm, so, I like to cancel them all out.  here is a simple PowerShell scripts that will do just that.  This script was originally developed for SharePoint 2010, but also works on SharePoint 2013 just fine.  It was originally developed by Justin Brink based upon a script written by Serge Luca.

#Cancel all workflows in a specific list $web = Get-SPWeb "[site URL]"; $web.AllowUnsafeUpdates = $true; $list = $web.Lists["[list name]"]; foreach ($item in $list.Items) { foreach ($wf in $item.Workflows) { [Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf); } } $web.Dispose();

References

No comments: