How to stop SharePoint 2010 workflows in SharePoint online environment using a PowerShell script

Rajshri J Thorat 1 Reputation point
2020-11-04T10:37:47.49+00:00

Hi,

We have migrated all the sites to SharePoint online environment , I have to write the PowerShell script to stop the SharePoint 2010 workflow instances on list

We are trying to use below CSOM code in PowerShell

Guid workflowInstanceGuid;
Guid.TryParse(listItem["WorkflowInstance"].ToString(), out workflowInstanceGuid);
interopService.CancelWorkflow(workflowInstanceGuid);
context.ExecuteQuery();

but i am not able to find the workflow instance GUID to passs as parameter , for the 2010 workflow in SharePoint online

Please help use to find the accurate code or command so we can stop the 2010 Workflow.

Please suggest if any other option is there to do this

Thanks ,
Rajashri Thorat

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,088 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,438 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amos Wu-MSFT 4,051 Reputation points
    2020-11-05T06:00:32.787+00:00

    The CancelWorkflow function should be a server-side function. In SharePoint Online,we could not call use any server-side class and function.
    And as I test,pnp powershell can not get 2010 workflow instance too.
    37569-image.png
    ShaePoint 2010 Workflow retires soon, please migrate as soon as possible.
    Reference:SharePoint 2010 workflow retirement


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.