We have over a thousand approval workflows running and I would like to write a PowerShell script to go through and approve the items from the system account. I already wrote the script to get the correct workflow tasks from the "Workflow Tasks" library but when I try and set those tasks to approved they don't seem to fully update. Here are the Properties I am currently setting:
$task[[Microsoft.SharePoint.SPBuiltInFieldId]::WorkFlowVersion]=1 $task["Outcome"] = "Approve" $task["Status"] = "Completed" $task["% Complete"] = 1 $task["ApprovalOutcome"] = 2 $task["TaskStatus"] = "Approved" $task["Decision"] = 2 $task["Completed"] = $true $task.Systemupdate()
This seems to set the workflow as complete from the list view but when you go into the workflow task properties the "Primary Approval Status" and Approval Status fields are still in a pending state. The workflow also does not see the task as complete. The fields in the list view show it as complete though, for instance the "Status" field shows "Completed, the "% Complete" field shows "100%, the "Outcome" field shows "Approve"
Has anyone ever used PowerShell to approve workflow approval tasks? It should be noted we are actually using Nintex workflows but I am pretty sure the workflow Approval task behaves the same as an out of the box workflow would.