Skip to main content
Nintex Community Menu Bar

How to locate Nintex Workflows via PowerShell

  • December 12, 2014
  • 2 replies
  • 158 views
  • Translate

Forum|alt.badge.img+10

Products: Nintex Workflow 2013, Nintex Workflow 2010

 

We have often seen the requirement to be able to report on how many Nintex Workflows are in an environment and where they are.

 

Using this PowerShell script you can generate a report of how many workflows are found on each site/subsite/list in a SharePoint environment.

 

Note: This script only targets the Nintex Configuration Database. Update: Script now targets all Nintex databases.

 

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
  1. Add-PSSnapin Microsoft.SharePoint.PowerShell
  2.  
  3. [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
  4. [void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Workflow")
  5. #[void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Workflow.SupportConsole")
  6. [void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Workflow.Administration")
  7. [void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Forms.SharePoint.Administration")
  8.  
  9. $cmd = New-Object -TypeName System.Data.SqlClient.SqlCommand
  10.  
  11. $cmd.CommandType = [System.Data.CommandType]::Text
  12.  
  13. $cmd.CommandText = "SELECT
  14.                COUNT (DISTINCT workflowid)as NumberofWorkflows,
  15.                SiteID,
  16.                WebID,
  17.                listid
  18. FROM WorkflowInstance I inner join WorkflowProgress P
  19.                ON I.InstanceID = P.InstanceID
  20. GROUP BY GROUPING SETS((i.siteid, i.webid, i.listid), ());"
  21.  
  22. $indexes = @()
  23.  
  24. foreach ($database in [Nintex.Workflow.Administration.ConfigurationDatabase]::GetConfigurationDatabase().ContentDatabases)
  25. {
  26.  
  27. $reader = $database.ExecuteReader($cmd)
  28.  
  29. while($reader.Read())
  30. {
  31. $row = New-Object System.Object
  32.  
  33. if(![string]::IsNullOrEmpty($reader["SiteID"])){
  34. $Site = $(Get-SPSite -identity $reader["SiteID"])
  35. }
  36.  
  37. if(![string]::IsNullOrEmpty($reader["WebID"])){
  38. $SubSite = $Site.Allwebs[[Guid]"$($reader["WebID"])"]
  39. }
  40. if(![string]::IsNullOrEmpty($reader["ListID"])){
  41. $List = $SubSite.Lists[[Guid]"$($reader["ListID"])"]
  42. }
  43.  
  44. $row | Add-Member -MemberType NoteProperty -Name "Number Of Workflows" -Value $reader["NumberofWorkflows"]
  45. $row | Add-Member -MemberType NoteProperty -Name "Site Collection" -Value $Site.Url
  46. $row | Add-Member -MemberType NoteProperty -Name "Subsite" -Value $SubSite
  47. $row | Add-Member -MemberType NoteProperty -Name "List" -Value $List.title
  48.  
  49. $indexes += $row
  50. }
  51. }
  52. $indexes
 
Did this topic help you find an answer to your question?

2 replies

  • Novice
  • 1 reply
  • June 2, 2017

Do I need to modify anything within this script for it to work with my SharePoint site?  I am getting the following errors when I run the script from the application server:

Exception calling "ExecuteReader" with "1" argument(s): "Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."
At C:AdminScriptslocate-workflowslocate-workflows.ps1:27 char:34
+ $reader = $database.ExecuteReader <<<< ($cmd)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression.
At C:AdminScriptslocate-workflowslocate-workflows.ps1:29 char:19
+ while($reader.Read <<<< ())
    + CategoryInfo          : InvalidOperation: (Read:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Translate

  • 1 reply
  • November 17, 2021

I'm getting this same error...what can be done to resolve to run this script?

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings