cancel
Showing results for 
Search instead for 
Did you mean: 

How to quickly identify large workflows in SharePoint

Workflow Hero
16 6 2,753

Products: Nintex Workflow 2016, Nintex Workflow 2013, Nintex Workflow 2010

A common cause of workflow failure is size. Additionally, large workflows can cause widespread performance issues in your SharePoint farm. This article provides instructions on how to locate large workflows.

Run the below (attached as well as a *.txt file for your convenience) PowerShell script (PowerShell ISE works well) from a SharePoint Server:

PowerShell Script

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Workflows that are larger (in Kb) than threshold will be returned.
[int]$threshold = 500

function Get-WorkflowFolders {
PARAM
(
[Parameter(ValueFromPipeline=$true)] [Microsoft.SharePoint.SPWeb] $SPWeb
)

BEGIN {
  }

END {
}

PROCESS {
  $SPWeb.GetFolder("Workflows").SubFolders
  $SPList = $null
  [GC]::Collect()
}
}

function Get-WorkflowData{

PARAM
(
[Parameter(ValueFromPipeline=$true)] [Microsoft.SharePoint.SPFolder] $SPFolder
)

BEGIN {
  }

END {
}

PROCESS {
        $obj = New-Object -TypeName PSObject -Property @{

        WorkflowSize = [Int]0
        ParentWebUrl = $SPFolder.ParentWeb.Url
        FolderUrl = $SPFolder.Url
        Url = $SPFolder.ParentWeb.Url + "/" + $SPFolder.Url

        }

  $SPFolder.Files | ForEach-Object{$obj.WorkflowSize += [Int]$_.Length}

        $obj

  $SPFolder = $null
        $obj = $null
  [GC]::Collect()
}

}

$(Get-SPWebApplication) | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | Get-WorkflowFolders | Get-WorkflowData | where {$_.WorkflowSize -gt $($threshold * 1024)} | FT Url, WorkflowSize

The size of workflows returned can be adjusted by modifying the $threshold variable (default is 500 or 500kb).

6 Comments
Not applicable

This is great, Aaron!

Workflow Hero

Does this apply to Nintex for Sharepoint 2016 also?

Not applicable

Yes, it does work for SharePoint 2016.  I have updated the post to reflect that.

Workflow Hero

I see a difference in the size of the Nintex workflow  between the .nwf exported from  SP 2013 site settings-> Nintex Workflow gallery  and the output of the powershell from the script given in this article. If the exported .nwf file is 586 kb but the corresponding output of powershell for that workflow entry  was 1.24 gb.. please clarify me on this  size difference

Workflow Hero

I saw the same issue as Deepti Kumar, above. For example, one exported workflow was 599 KB, but the PowerShell script showed the same workflow as 743kb. Which size is accurate? 

Workflow Hero

743kb is correct as this is the actual workflow size in SharePoint.