Unable to start/stop workflow instances associated with a List Item

Nirenjana Raghupathy 21 Reputation points
2024-05-30T01:15:27.9533333+00:00

Hi All,

I'm trying to stop workflow instances attached to a specific List Item In a SharePoint List. But I notice the workflow subscription command always returns null, due to which Stop-PnPWorkflowInstance fails.

#Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber

#Install-Module -Name Microsoft.PowerApps.Administration.PowerShell

#connect with PROD Azure environment

#Connect-AzureAD -TenantId

#Add-PowerAppsAccount

$environments = Get-FlowEnvironment #This is to get all available Environment in our Power Automte Tenant

foreach($environ in $environments.EnvironmentName) #Cycle to all Environments

{

$flows = Get-Flow –EnvironmentName $environ 

foreach ($flow in $flows) #Loop to each PowerAutomate workflow Available

{

    if($flow.DisplayName -eq "wfName")

    {  

        $WFSubscription = Get-PnPWorkflowSubscription -List "List title" -Name "wfName"

        $WFSubscriptionName = $WFSubscription.Name

        Stop-PnPWorkflowInstance -ListItem 9701 -Subscription $WFSubscription

}

}
```}

Please let me know what is incorrect here?
SharePoint Workflow
SharePoint Workflow
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Workflow: An orchestrated and repeatable pattern of business activity, enabling data transformation, service provision, and information retrieval.
541 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,240 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 43,331 Reputation points Microsoft Vendor
    2024-05-30T09:52:19.9833333+00:00

    Power Automate is currently not supported in the Q&A forum.

    Please start a new discussion via the Power Automate Community so that you can get dedicated support on this issue.

    Thank you for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    0 comments No comments