After a long time, faced with a different scenario. The site collection has various lists and there are a lot of Nintex workflows associated to those lists. I was about to populate data for those lists using a backend mechanism, but don’t want those workflows to be triggered. Provided the Scenario, I don’t want to delete and attach the workflows again. Rather, there is an option called “No New instances” in the workflow properties. But, since we had many lists, can’t do this manually. Hence, came up with a script. Thought of sharing with the community.
When we do manually, we will go to the workflow settings of the list and click on the “Remove, Block or Restore a workflow”
Once, we click that, the next screen would be as below where we can toggle between the properties.
The below script will toggle this property.
Clear-Host
# Connects and Creates Context
Connect-PnPOnline https://SiteCollectionURL -CurrentCredentials
[System.Collections.ArrayList]$listsToUpdateWorkflowStatus = Get-PnPList | Where-Object {$_.Title.StartsWith('Our Lists Prefix') }
$ctx=Get-PnPContext
foreach ($list in $listsToUpdateWorkflowStatus)
{
$ctx.load($list.WorkflowAssociations)
$ctx.ExecuteQuery()
$list.WorkflowAssociations
$workflowAssociation = $list.WorkflowAssociations[0]
# $workflowAssociation.DeleteObject()
$workflowAssociation.Enabled = $false
$workflowAssociation.Update()
$list.Update()
$ctx.ExecuteQuery()
}
Happy Coding,
Sathish Nadarajan.
Leave a comment