cancel
Showing results for 
Search instead for 
Did you mean: 

Speed up workflow processing with PowerShell

aaron_labiosa
Nintex Newbie
27 7 1,851

Products: Nintex Workflow 2013, Nintex Workflow 2010

WARNING: THIS SHOULD NEVER BE USED IN A PRODUCTION ENVIRONMENT

When working on a workflow in a development environment it is often desirable to run through many instances of a workflow under various conditions. If the workflow utilizes pauses, this can be quite cumbersome when testing. This PowerShell script can be run on a development server to force the Workflow Timer job to run at a specified interval with no minimum (Example: 5 seconds) making testing a lot faster.

Since this script does not actually modify anything, it makes it easy to turn it off and on during your testing cycles.

PowerShell Script
  1. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  2. $job = $(Get-SPTimerJob -Identity 'job-workflow')
  3. while($true)
  4. {
  5.     $job.RunNow()
  6.     Start-Sleep(10)
  7. }

To use the script do the following:

  • Ensure you are running the PowerShell console as a SharePoint Administrative account.
  • Configure the value in "Start-Sleep" to the interval the workflow timer job should run at.
7 Comments
Automation Master
Automation Master

Super helpful for testing, but please note the warning.

aaron_labiosa
Nintex Newbie

What he said! I am hoping this will help slow down cases we see where folks have modified the timer job definition schedule from the default 5 minutes.

Automation Master
Automation Master

This is awesome.   I can't tell you how many minutes of my life have been wasted waiting for those state machine changes.. LoL

aaron_labiosa
Nintex Newbie

I know right! That and demos... There is nothing quite like sitting there waiting on something that under normal circumstances would not matter as much...

Automation Master
Automation Master

Totally,  I always have to tell people in demos "well in real life 5 minutes is nothing..." but in testing and demoing, painful!

Not applicable

Just to clarify, does the Start-Sleep(10) line set the new interval back to 10 minutes vs. the default of 5 minutes?

thurjs35
Nintex Newbie

The script is a simple loop that will continually execute the timer job called "job-workflow" and in each iteration it does two things:

-executes the job-workflow timer job

-sleeps 10 seconds

The sleep is just probably intended to throttle the frequency that PowerShell executes the timer job as to not cause any contention with resources.

The actual schedule on the timer job in SharePoint isn't modified and this script will run until you stop it.  It's basically bypassing the original timer job schedule by executing it immediately in PowerShell.