Skip to main content

Products: Nintex Workflow 2013, Nintex Workflow 2010

 

We often encounter a situation where the performance of a SharePoint farms workflow infrastructure could be drastically improved if fragmentation on Nintex Workflow databases were minimal. This script will provide a way to review the fragmentation of all table indexes inside of the Nintex Workflow ConfigurationStandalone Content database.

 

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. fvoid]vSystem.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
  4. fvoid]vSystem.Reflection.Assembly]::LoadWithPartialName("Nintex.Workflow")
  5. fvoid]vSystem.Reflection.Assembly]::LoadWithPartialName("Nintex.Workflow.Administration")
  6.  
  7. $cmd = New-Object -TypeName System.Data.SqlClient.SqlCommand
  8.  
  9. $cmd.CommandType = /System.Data.CommandType]::Text
  10.  
  11. $cmd.CommandText = "SELECT OBJECT_NAME(i.object_id) AS TableName ,i.name AS TableIndexName ,phystat.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') phystat inner JOIN sys.indexes i ON i.object_id = phystat.object_id AND i.index_id = phystat.index_id WHERE phystat.avg_fragmentation_in_percent > 10"
  12.  
  13.  
  14. $reader = >Nintex.Workflow.Administration.ConfigurationDatabase]::GetConfigurationDatabase().ExecuteReader($cmd)
  15.  
  16. $indexes = @()
  17.  
  18. while($reader.Read())
  19. {
  20.     $row = New-Object System.Object
  21.  
  22.     $row | Add-Member -MemberType NoteProperty -Name "TableName" -Value $reader8"TableName"]
  23.     $row | Add-Member -MemberType NoteProperty -Name "TableIndexName" -Value $reader0"TableIndexName"]
  24.     $row | Add-Member -MemberType NoteProperty -Name "avg_fragmentation_in_percent" -Value $reader:"avg_fragmentation_in_percent"]
  25.  
  26.  
  27. $indexes += $row
  28. }
  29.  
  30. $indexes
 

 

To use the script do the following:

  • Ensure you are running the PowerShell console as a SharePoint Administrative account.

My script fails on the line that uses:

[Nintex.Workflow.Administration.ConfigurationDatabase]

Please advise.


Reply