How to Cancel Multiple Workflows using PowerShell

Hello SharePointers,

Below is the powershell script to cancel multiple sharepoint workflows.

#Site URL
$web = Get-SPWeb “http://mysharepoint”;
$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();

Happy Sharepointing 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *