Skip to main content

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

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 FilesCommon FilesMicrosoft SharedWeb Server Extensions15BINNWAdmin.exe" -o PurgeWorkflowData -siteCollectionUrl %1 -lastActivityBeforeLocal %2 -state Completed < %3PurgeWfDataTest-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.

 


Hi Markan,

This is awesome i have created same thing as per your instructions i have scheduled PowerShell in windows task scheduler, when through PowerShell console i am calling your PowerShell script it triggering cmd file as expected and doing job. 

Now problem i am facing when it is scheduled through task scheduler and when doing run from task scheduler it is showing only showing status, its is not going end somewhere or stopping .. just showing running.

 

Can you tell me any thing i am doing wrong or missing here.

Thanks

Girish K.

 


Reply