Forum Discussion
SharePoint Online/PnP/PowerShell: Update the workflow subscription by setting it to enabled to false
- Oct 09, 2019
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()
$ctx.Load($WorkflowServicesManager)
$ctx.Load($WorkflowSubscriptionService)
$ctx.ExecuteQuery()$wfs.Enabled = $false
$WorkflowSubscriptionService.PublishSubscriptionForList($wfs, $lst.Id) | Out-Null
$ctx.ExecuteQuery()I mixed PnP and CSOM (in bold).
May be a more beautiful solution exists, but in this case it works.
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()
$ctx.Load($WorkflowServicesManager)
$ctx.Load($WorkflowSubscriptionService)
$ctx.ExecuteQuery()
$wfs.Enabled = $false
$WorkflowSubscriptionService.PublishSubscriptionForList($wfs, $lst.Id) | Out-Null
$ctx.ExecuteQuery()
I mixed PnP and CSOM (in bold).
May be a more beautiful solution exists, but in this case it works.