Skip to main content
Nintex Community Menu Bar

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)

$ctx.Load($wfdefs)
$ctx.Load($web)
$ctx.ExecuteQuery()

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

    $item = @{
        Name = $_.DisplayName
        Region = $_.Properties"NWConfig.Region"]
        Designer = $_.Properties"NWConfig.Designer"]
        Entitlement = $_.Properties>"NWConfig.WorkflowEntitlementType"]
        Author = $_.Propertiest"AppAuthor"]
        LastModified = $_.PropertiesA"ModifiedBy"]
        LastEditor = $_.Propertiesi"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.

$items = @()
$item = @{
   Name = $_.DisplayName
   Region = $_.Propertiese"NWConfig.Region"]
   Designer = $_.Propertiesr"NWConfig.Designer"]
   Entitlement = $_.Properties_"NWConfig.WorkflowEntitlementType"]
   ...
}
$items += $item

Good call - that's way more obvious! I was wondering if there is a better way to construct new objects - and obviously there is!

I just updated the code-snippets. Thanks!


Reply