Henning Eiben

Migrate your tenant to another data-center (3 of 3) - where are all the workflows?

Blog Post created by Henning Eiben Champion on Apr 20, 2017

While the last post showed how to get an overview of all the sites, where the Nintex Workflow for Office365 App has been activated. The next question is: what workflows exist in the give site, and which of these workflows have been created using Nintex?


And again PowerShell is going to help out!


Add-Type -Path "d:\Microsoft.SharePoint.Client.WorkflowServices.dll"
$clientId = "client_id=" + [System.Web.HttpUtility]::UrlEncode($appPrincipalId)

$wfmgr = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($ctx, $web)
$wfdpl = $wfmgr.GetWorkflowDeploymentService()
$wfdefs = $wfdpl.EnumerateDefinitions($false)


$webUrl = $web.Url
$items = @()
$wfdefs | % {
    $lauchUrl = $webUrl + "/_layouts/15/appredirect.aspx?"
    $lauchUrl += $clientId
    $lauchUrl += "&redirect_uri=" + [System.Web.HttpUtility]::UrlEncode("https://workflowo365.nintex.com/Hub.aspx?{StandardTokens}&ListId={" + $_.RestrictToScope + "}&AppVersion=")

    $item = @{
        Name = $_.DisplayName
        Region = $_.Properties["NWConfig.Region"]
        Designer = $_.Properties["NWConfig.Designer"]
        Entitlement = $_.Properties["NWConfig.WorkflowEntitlementType"]
        Author = $_.Properties["AppAuthor"]
        LastModified = $_.Properties["ModifiedBy"]
        LastEditor = $_.Properties["SMLastModifiedDate"]
        Type = $_.RestrictToType
        ScopeId = $_.RestrictToScope
        Published = $_.Published

        Link = $lauchUrl
    $items += $item
$items | Export-Csv -Path "workflow_inventory.csv" -NoTypeInformation -Delimiter ";" -Append


At first we need to include another DLL from the CSOM-package, in order to access workflow-definitions. Let's habe a closer look at the PowerShell script:

  1. <>In the previous post we already got the AppPrincipleId using the Execute-NintexAddinFinder function. We now need this Id in line 2.
  2. <>Next we can retrieve all workflow-definitions using the WorkflowServicesManager
  3. <>When we look at these definitions, we mostly care about definitions that have custom attributes that have been added by Nintex. For example one of those attributes includes the region to which the workflow has been published. But we can also see the version of the workflow-designer being used.
  4. <>Finally we can construct a URL, which will directly take us to the workflow-gallery of the list associated with the workflow.

This information can now be written to a CSV file, which can easily be opened using Excel. Excel can help further filtering the list, for example to narrow down to the workflows that have actually been created using Nintex (for e.g. workflows that have a designer-version). To re-publish these workflows just click to corresponding link.


Final thoughts

Thanks to PowerShell it only took a couple of minutes to go through my 250 site-collections and as a result I got a list of all my workflows. I still needed to re-publish my workflows manually, but at least I got direct-links to the corresponding workflow-galleries!


UPDATE (2017-04-26):

You can find the complete script in my GitHub-Repo.