What to do once you have disabled the Workflow Cleanup Timer Job

Published May 15 2019 03:10 PM 116 Views

First published on TECHNET on Jan 22, 2015

Sooooooo you have figured out that you disabled the Workflow History Cleanup timer job, and now realize the mistake you made....


My customer recently found themselves in that position, this customer had done this to allow a Site Collection to use that data for auditing purposes and as I said a few weeks ago this is a mistake, see previous blog for more info.  Sadly they could not just enable the job and go on there merry way, they had to export that data and keep it somewhere for the Site Collection owner could go back and review when needed.


I wrote this PowerShell script to do just that for them.  Here is what I did

    1. Script enumerates all Workflow History lists and places the title into an array for later use


    1. Going thru the array we open each list and perform the following steps:

    1. Dump the whole list unmanipulated to a text file (In case there are questions in future)


    1. Start going thru list data and gather Date of event, Event Type, User id, Description, Outcome, and the item that was affected


    1. Write manipulated data to a CSV

In the script there are a few tricks I had to do to complete the job, and I would like to point them out


1. Get all Workflow history lists title into an array, I used the SPList Porperty BaseTemplate



2. The list items data for the event is a number and thanks to the author of this article http://www.spjeff.com/2010/01/29/workflow-history-event-type-numbers-decoded-2/ I was able to use a simple switch statement to translate the number to provide a more descriptive event.



3. To extract the name of a document for the workflow I had to take several steps


a. Create a regexpattern to find url of documents



b. Then manipulate the data to get the name of the document



If you would like to please download the script from here

Version history
Last update:
‎Apr 28 2020 03:16 PM
Updated by: