How to cancel all workflows from one List in SharePoint using PowerShell?

This SharePoint workflow tutorial explains, how to cancel all workflows from one list in SharePoint using PowerShell. It will cancel all list workflows as well as site workflows from the SharePoint list.

We have tested this PowerShell script in our environment, Hope it will work for you.

PowerShell: Terminate a workflow for all items in a list on SharePoint

#Site URL
$web = Get-SPWeb "http://urlforsite.com";
$web.AllowUnsafeUpdates = $true;

#List Name
$list = $web.Lists["ListName"];

# Iterate through all Items in List and all Workflows on Items.
foreach ($item in $list.Items) {
foreach ($wf in $item.Workflows) {

#Cancel Workflows
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);
}
}
$web.Dispose();

Cancel all workflows from SharePoint List using PowerShell

Below is the PowerShell script to cancel all workflows from the SharePoint list using PowerShell.

$site = Get-SPSite "<your url>";
$site.AllWebs | foreach {
$web = $_;
$web.AllowUnsafeUpdates = $true;

# stop list workflows
$web.Lists | foreach {
$list = $_;
$list.Items | foreach {
$item = $_;
$item.Workflows | foreach {
$wf = $_;
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);
}
}
}

# stop site workflows

$web.Workflows | foreach {
$wf = $_;
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);
}
$web.AllowUnsafeUpdates = $false;
$web.Dispose();
}

$site.Dispose();

You may like following PowerShell SharePoint tutorials:

I hope this will be helpful to cancel all workflows from a SharePoint list using PowerShell in SharePoint 2013.

Tags: SharePoint cancel workflows in progress, cancel all workflows on a list, cancel all workflows on a list SharePoint 2013, cancel all workflows SharePoint 2013, cancel all workflows SharePoint 2013 using PowerShell

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

>