Terminate SharePoint Workflows via PowerShell

Problem Description:

​Workflow cannot be terminated in the GUI

Resolution:

Stop the workflow on PowerShell

$web = Get-SPWeb “WebUrl”
$web.AllowUnsafeUpdates = $true;

$list = $web.Lists[“Listname”];

$wfm=New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$workflowInstanceService=$wfm.GetWorkflowInstanceService()
$workflowInstance=$workflowInstanceService.EnumerateInstancesForListItem($list.ID,ItemID)
$workflowInstance

$mywfi = $workflowInstanceService.EnumerateInstancesForListItem($list.ID,ItemID) | where ID -eq WFIID

$workflowInstanceService.TerminateWorkflow($mywfi)
$web.Dispose()

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...