vCommander® provides a means to troubleshoot and track workflows, but doing so within the user interface is not always the best option when there are large numbers of workflows that must be closed at once. This can happen, for example, when a frequently used workflow is misconfigured or an environmental problem generates failures. Under such circumstances, a means to close the workflows in bulk becomes necessary.

There are two ways that you can close the workflows in bulk: using a SQL query (available in all versions of vCommander), or via the REST API (available in vCommander 5.7.8 and later). When both options are available, it's recommended that the REST API be used. The REST API progresses the workflows as would normal user interactions, rather than overwriting the state.


vCommander 5.7.8 and later provide enhanced workflow management capabilities, including the ability to skip a workflow or workflow step, repeat a workflow step and paginate through lists of workflows. 

The PowerShell script below (attached as a zip) provides an example of how to call the API to skip all failed workflows so that they proceed to the completed state. Before running it, you must edit it as follows:

$Global:SERVICE_HOST =""
Specify the address of your vCommander server.
$Global:CREDENTIAL = New-DecryptCredential -keyFilePath "C:\\scripts\\vcmdr_credential_key.xml"
Specify the path to your encrypted credentials file. Use double slashes in the file path.
$minDaysOldToClose = 3
Specify the minimum age in days that a workflow must be in order to be closed. Default is 3.

$moduleName = "VCommanderRestClient"
If (-not (Get-Module -name $moduleName)) {
  Import-Module -Name $moduleName 
$moduleName = "VCommander"
If (-not (Get-Module -name $moduleName)) {
  Import-Module -Name $moduleName 
try {
    $Global:SERVICE_HOST =""
    $Global:REQUEST_HEADERS =@{}
    $Global:BASE_SERVICE_URI = $Global:BASE_SERVICE_URI_PATTERN.Replace("{service_host}",$Global:SERVICE_HOST)
    $Global:CREDENTIAL = New-DecryptCredential -keyFilePath "C:\\scripts\\vcmdr_credential_key.xml"
    $minDaysOldToClose = 3
    $offset = 0
    $wfCount = 0
    $numSkipped = 0
    do {
        $workflows = Get-RunningWorkflowsByStatus -workflowStatus ERROR -max 10 -offset $offset
        $wfCount = $workflows.RunningWorkflowCollection.RunningWorkflows.Count
        $offset = $offset + $wfCount 
        Write-Host "Found group of $($wfCount) failed workflows"
        foreach($workflow in $workflows.RunningWorkflowCollection.RunningWorkflows) {
            $daysSinceStart = (New-TimeSpan -Start $workflow.startTimestamp).TotalDays
            Write-Host "$($ failed against $($ - started $($daysSinceStart) days ago"
            if($daysSinceStart -gt $minDaysOldToClose) {
                Write-Host "Started more than $($minDaysOldToClose) day ago, skipping workflow"
                $numSkipped = $numSkipped + 1
                Invoke-SkipRunningWorkflow -workflowId $ -comment "Workflow failure occured more than $($minDaysOldToClose) day(s) ago"
    } while($wfCount -gt 0);
    Write-Host "Skipped $($numSkipped) old failed workflows out of $($offset) total failed workflows"
} catch {
    Write-Host "Error: $($_)"

For more information on using the Embotics PowerShell client and libraries to run this script, refer to the article Download vCommander REST Client. You can also schedule this to run as a task using the Windows Task Scheduler.

Using SQL

As with any solution that makes direct changes to your database, Embotics recommends that you back up your database prior to running the query below. 

update workflow set status = 1, progress = null, current_step_id = null where name like '%Decomm_workflow%' and endtimestamp is NULL;

The query shown here will set all workflows with a name like Decomm_workflow that do not have a workflow end timestamp to the status of completed. You can update the query to target other names by replacing the text between the percentage signs. You can also set different statuses by using their ID instead of using 1 to indicate Completeled. Typically you will want Completed or Rejected.