Ensure_List_WorkflowAssociation_Enabled

Useful for disabling (or re-enabling) a LIST based workflow
Language:
PowerShell
Keywords:
SharePoint
Code Snippet

Function Ensure_List_WorkflowAssociation_Enabled( [Microsoft.SharePoint.SPList]$tList
                                                , $wfAssociationName
                                                , $wfEnabled
                                                ) {
    $tWorkflowAssociation = $tList.WorkflowAssociations | where { $_.Name -eq $wfAssociationName }
    if ($tWorkflowAssociation -ne $null -and
        $tWorkflowAssociation.Enabled -ne $wfEnabled) {
        $tWorkflowAssociation.Enabled = $wfEnabled
        Write-Output([System.String]::Format("List [{0}] Workflow Association [{1}] : Setting Enabled to [{2}]", $tList.Title, $wfAssociationName, $wfEnabled))
        $tList.UpdateWorkflowAssociation($tWorkflowAssociation)
    }
}


Created 2011-10-13
comments powered by Disqus
Login