IBM Support

Republish SharePoint Workflows after upgrading to new SharePoint Workflow Manager Server

How To


Summary

When upgrading or migrating to a new SharePoint Workflow Manager (WFM or SPWFM) server, it usually happens during SharePoint farm upgrades (e.g., from 2013/2016 to 2019 or Subscription Edition) or in disaster recovery situations. If the site scopes and definitions aren't aligned between SharePoint and the new WFM server, workflows might not start or run correctly. By republishing workflows using SharePoint Designer (SPD) 2013 or 2016, you re-register these workflows with the new WFM instance, thereby maintaining the operation of existing instances.

Objective

Microsoft provides instructions for republishing SharePoint Workflows on an individual site basis, which can be beneficial when dealing with a limited number of workflows in smaller settings. However, this approach may not be feasible for larger environments with numerous sites, each containing multiple workflows.

Environment

All versions of SharePoint.

Steps

1.      Ensure the new WFM server is fully configured.

·         Including database migration (backup/restore of WFM databases like SbManagementDB, WorkflowManagementDB, etc.) and registration with SharePoint via PowerShell:

Register-SPWorkflowService -SPSite https://SharePointSite.contoso.com/sites/HW-Collaboration -WorkflowHostUri "https://ShaePointServerName.contoso.com:12290 -AllowOAuthHttp -Force

 

2.      Open SharePoint Designer and Connect to the Site

·         Launch SharePoint Designer 2013 (or 2016 for newer farms).

·         Go to File > Open Site and enter the affected site's URL.

·         Authenticate with farm admin credentials (ensure the account has Full Control on the site collection).

·         The 2013 workflow option will be visible in the drop-down menu; however, the workflows will not be present and need to be republished

 

3.      Save the below script as Republish.ps1 and run with SP WorkFlow Manager Service account

·         Replace Web App URL with the URL used to register the Workflow Manager Service above. For example https://SharePointSite.contoso.com

 

Add-PSSnapin Microsoft.SharePoint.PowerShell

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WorkflowServicesBase")

$webapp = Get-SPWebApplication  "Web App URL"

foreach ($site in $webapp.Sites)

{

foreach ($web in $site.allwebs)

{

$wfm = new-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)

$ds  = $wfm.GetWorkflowDeploymentService()

$col = $ds.EnumerateDefinitions($false)

$wss = $wfm.GetWorkflowSubscriptionService()

foreach($spworkflow in $col)

{

   Write-Output $spworkflow.DisplayName

   $ds.SaveDefinition($spworkflow)

   $ds.PublishDefinition($spworkflow.Id)

   $ws = $wss.EnumerateSubscriptionsByDefinition($spworkflow.Id)

   if($ws -ne $null)

   {

      $wss.PublishSubscription($ws[0])

   }

}

}

}

 

·         The republishing process could require a few hours to complete, the duration being contingent on the quantity of workflows undergoing republishing.

·         A test for functionality should be conducted upon finishing the PowerShell script.

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"","label":""},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSCPJ33","label":"SharePoint Server"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":""}]

Document Information

Modified date:
22 October 2025

UID

ibm17248854