Bulk delete SharePoint workflow tasks with associated history items using PowerShell

Standard

I Written this script to bulk delete old completed workflow tasks with related history items by specify the date that script will stop delete until it.

The script were treated to deal with a huge number of data.

Click here to download The script

Click here to download from TechNet Gallery

Notes:

1. Read the Instructions in the top of the file to set the script parameters

Bulk delete SharePoint workflow tasks with related history

Script Instructions part

Bulk delete SharePoint workflow tasks with related history items

Script Parameters part

2.  The Script query to select all items with status = completed and date before specific date , be attention to modify the query for non English task status

3. Script will not delete from the SharePoint recycle bin because of slowness ,  the best solution from my opinion is to disable the recycle bin from the central administration before run the script that will delete all items from the SharePoint content database ” that is our target ”

4. You can run the script in log mode only that will log all items to delete and will log the batch messages for tasks and history items without actual delete by set the $LogOnly variable to $true ( follow the  instructions in the top of the file to do that )

The biggest problem that i faced is the quotation marks for the batch XML message but this post save my time , thanks to the writer  🙂 🙂

http://www.theodells.org/theodells/blog/2012/10/powershell-function-to-delete-all-sharepoint-list-items

Have a nice SharePoint administration 🙂

Advertisements

2 thoughts on “Bulk delete SharePoint workflow tasks with associated history items using PowerShell

  1. Why wouldn’t you just modify the workflow’s task behaviour to delete tasks upon completion?? Or if the tasks are manually created, add an event received that deletes items whose status is Completed…

    • You are right if you design the solution from the beginning , but the solution provided in this post for whom used the SharePoint since 2010 with a wrong way while they designed their workflows to put all tasks in one task list !

      Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s