Nintex

Cancel Nintex workflow stuck Instance using PowerShell

Posted on Updated on

In this post we are going to apply a PowerShell script to cancel all stucked workflow in Nintex

This script is used to run for SharePoint 2010, SQL Server 2008 R2, but it still can be used for other versions after running it on Stage environment

Take a copy from the below script and run it on the SharePoint server that contains Nintex workflows

if( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.SharePoint.PowerShell
}
$web = Get-SPWeb "https://Microsoft.com/Sites/YourSite";
$web.AllowUnsafeUpdates = $true;
$list = $web.Lists["Your WorkFlow Configuration list"];
foreach ($item in $list.Items)
{
foreach ($wf in $item.Workflows)
{
if ($wf.InternalState -eq "Completed")
{
# Nothing To Do
}
else
{
# Writes Workflow Status
Write-Host $wf.InternalState
#Cancel Workflow
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);
}
}
}
$web.Dispose();

 

Advertisements