SharePoint Online/PnP/PowerShell: Update the workflow subscription by setting it to enabled to false

Copper Contributor

I try to update the "Enabled" property of a workflow subscription in SharePoint Online with PnP PowerShell but nothing append. My goal is to set programmaticaly this action as in UI when you can navigate to the Remove Workflow (RemWrkfl.aspx) page end then choose "No New Instances". Here it is what I do:

Import-Module SharePointPnPPowerShellOnline -DisableNameChecking
Connect-PnPOnline -Url "web_site_url"
$wfs = Get-PnPWorkflowSubscription -Name "WF_Name" -List "Lists/list_Name"
$wfs.Enable = $false


After this last command, I don't know what I need to do to activate this new property.

Can anyone help me, please?

1 Reply
best response confirmed by francois77 (Copper Contributor)

I finally found a solution:


$ctx = Get-PnPContext
$lst = Get-PnPList -Identity "Lists/list_Name"
$wfs = Get-PnPWorkflowSubscription -Name "WF_Name" -List $lst

$WorkflowServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($ctx, $ctx.Web)
$WorkflowSubscriptionService = $WorkflowServicesManager.GetWorkflowSubscriptionService()

$wfs.Enabled = $false

$WorkflowSubscriptionService.PublishSubscriptionForList($wfs, $lst.Id) | Out-Null


I mixed PnP and CSOM (in bold).

May be a more beautiful solution exists, but in this case it works.