cancel
Showing results for 
Search instead for 
Did you mean: 
marekan
Nintex Newbie

Purging workflow data automatically on schedule

Jump to solution

Hello all,

anyone knows if there is any way how to create kind of a task in CA for instance to use PurgeWorkflowData with certain parameters, which would run regularly instead of having to go to CA, set the filter Run the query and purge it manually?

 

Or anyone knows how to use NWAdmin.exe with filter parameters in powershell script?

 

All I so far found is the creation of the batch files and then windows tasks out of it, which I find quite cubersome for such important task to do.

 

I would expect this option to be configurable in CA..

 

Thanx for any kinda reply.

 

Jan

Labels: (1)
0 Kudos
Reply
1 Reply
marekan
Nintex Newbie

Re: Purging workflow data automatically on schedule

Jump to solution

If anyone is interested on one possible solution to this then I did it like this:

 

1) Powershell script which is looping through each needed site collection, setting up the last activity date before value into the variable and calling a batch file with this data to execute the PurgeWorkflowData command

 

if (!$PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent }
$logFilePath = $PSScriptRoot + "\Log_file.txt"
"Log" | Out-File $logFilePath -Force
$binary = "`"" + $PSScriptRoot + "\PurgeWfDataTest.cmd`"" 
$urls = "http://domain/sites/00001","http://domain/sites/00002"
$date = (Get-Date).AddDays(-30).ToString("MM/dd/yyyy")
foreach ($url in $urls) {
	write-output "& $binary $url $date $PSScriptRoot"
	Invoke-Expression "& $binary $url $date $PSScriptRoot"
	$url | Out-File -Append -FilePath $logFilePath
}

2) PurgeWfDataTest.cmd file which is being called from the PS script

cd %3
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN\NWAdmin.exe" -o PurgeWorkflowData -siteCollectionUrl %1 -lastActivityBeforeLocal %2 -state Completed  <  %3\PurgeWfDataTest-answer.txt

3) PurgeWfDataTest-answer.txt file containing just 'y' to confirm the NWAdmin.exe command called in point 2.

 

All files in one folder, windows task running the PS script.

 

View solution in original post

0 Kudos
Reply