I'm working on SharePoint Server 2016. Some monts ago I developed a 2013 Workflow using SharePoint Designer 2013. Today I noticed many Workflow instances are on status Started even they completed their job, so I decided to stop them manually from the UI (http://mySharePoint/_layouts/15/wrkstat.aspx?List={ListGuid}&WorkflowInstanceName=WFGuid). They don't stop.

Maybe buggy UI? ...I decided to wrote a powershell script:

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$sourceWebURL = "http://mySharePoint"
$sourceListName = [Guid]"ListGuid"
$web = get-spweb $sourceWebURL
$list = $web.Lists[$sourceListName]

$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$sub = $wfm.GetWorkflowSubscriptionService()
$wfs = $sub.EnumerateSubscriptionsByList($list.ID)
$wfis = $wfm.GetWorkflowInstanceService()

$item = $list.GetItemById($itemId)


foreach($wf in $workflowInstances) 

They don't stop either...

This is the scenario: enter image description here Each running WF is on Started, has done what it had to, but is not stoppable.

Somebody has an idea what's going on?


You can use the following PowerShell commands to cancel all workflow instances on the list.

$sourceWebURL = 'your site'
$sourceListName = 'your list'
$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]
$items = $spSourceList.getItems()

#-- Getting a Workflow manager object to work with.
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($spSourceweb)


Foreach($item in $items){
    $wfinstances =  $wfis.EnumerateInstancesForListItem($spSourcelist.ID, $item.ID);
    foreach($instance in $wfInstances)

| improve this answer | |
  • Could you explain me the differences to my code? – Emaborsa May 17 '18 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.