Showing results for 
Search instead for 
Did you mean: 
Nintex Newbie

Does any one have a PowerShell Script to cleanup Workflow Task Items

I found an interesting artlicle with a C# Snippet--enough to be intriguing but not enough for me to code from: 2013 - cleanup tasks from workflows and deleted items - SharePoint Stack Exchange :

int id = Convert.ToInt32(taskItem[SPBuiltInFieldId.WorkflowItemId]);
SPListItem item = list.GetItemById(id);

string workflowInstanceId = taskItem[SPBuiltInFieldId.WorkflowInstanceID].ToString();
SPWorkflow workflow = item.Workflows[new Guid(workflowInstanceId)];
If (workflow.StatusValue = SPWorkflowStatus.StoppedByUser)

Looking at SharePoint Manager, it seems that the Workflow Tasks have a field collection which contains among other things "WorkflowInstance".  I'd like to achieve this functionality in PowerShell to clean my Workflow Task.

I'm also looking for a way to cancel Workflows of deleted Items.

0 Kudos