سؤال

Is it possible to disable Workflow 2010 programmatically in SharePoint Online?

Workflows 2010 engine is not yet disabled at our tenant and will work until at least December 2021. As a result, we still have many SPD 2010 workflows that will need to be recreated using Power Automate. We would like to start disabling SPD 2010 workflows preemptively. This way we will know if anyone uses them.

So far I could not find a way to automate the process of disabling SPD 2010 Workflows. I will really appreciate any suggestions.

هل كانت مفيدة؟

المحلول

Run the following Powershell script as an administrator::

$url = "https://test.sharepoint.com/sites/projects";
$userName = "username@test.com"
$password = "*******"

$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)

Function Disable-WorkflowAssociations($url,$cred)
{
   try{
      $context = New-Object Microsoft.SharePoint.Client.ClientContext($url)
      $context.Credentials = $cred
      $AllLists=$context.Web.Lists
      #GetBYTitle can also be used
      $list=$AllLists.GetById("#Idhere") 
      $context.Load($list.WorkflowAssociations)
      $context.ExecuteQuery()
      foreach($wfAssociation in $list.WorkflowAssociations) {

         $wfAssociation.Enabled=$false
         $wfAssociation.Update()
         $context.ExecuteQuery();

         }
      }catch{
         write-host "Error: $($_.Exception.Message)"
      }
}

Disable-WorkflowAssociations -url $url -cred $cred
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top