See the rest of the blog posts

Using PowerShell to Admin Captaris Workflow

July 21, 2006

The other day I started looking into using PowerShell to help manage Captaris Workflow. The toughest part about coming up with any administration tool is imagining all the different tasks people might want to accomplish. One of the wonderful things about Powershell is that you don’t have to really know the details of how users want to manipulate the information. All you need to do is give the basic building blocks that can then be piped together to make something amazing. That was always the cool thing about piping commands in Unix. None of the individual utilities did much, but when piped together you could get amazing things done.

Anyway, one of the common tasks that Captaris Workflow admins like to do is to move old processes to an archive folder. We can do that via the GUI, but it is a multiple step process. So I created two simple Powershell scripts that will move any file, folder, process, or model from one location to another based on name, id, date modified, date created, owner, original location, and more. And to make it even better the two scripts together add up to 15 lines of code. If you only count the unique lines, its down to 9 lines.

So first off we want to get the list of records off the Workflow Server:

param($user=$(Throw “A user is required…”),$pwd=””)
[void][System.Reflection.Assembly]::LoadWithPartialName(“TeamplateBLL”) |out-null
$s = New-Object Teamplate.BLL.BSession

$f = New-Object Teamplate.BLL.BFileList
$f.SetSession($s) | out-null

[xml]$fld = $f.GetRecords()

return $fld.FileListDataSet.Files

This simply is connecting a session, using that session to get the list of records, then returning that list to the user. The next script just takes the ID of a record and moves it to the ID of another location:

param($FileID=$(Throw “A FileID is required…”),
  $FolderID=$(Throw “A Destination FolderID is required…”),
  $user=$(Throw “A user is required…”),
[void][System.Reflection.Assembly]::LoadWithPartialName(“TeamplateBLL”) |out-null
$s = New-Object Teamplate.BLL.BSession

$f = New-Object Teamplate.BLL.BFileList
$f.SetSession($s) | out-null


So now with these two scripts, which I have called get-wfrecords and move-wfrecord I can do some of the following really cool things:

  • Move all the Processes in Folder 123 to Folder 1:
    get-wfrecords admin | where{$_.type -eq “process” -and $_.parentid -eq 123} | foreach{move-wfrecord $ 1 admin}
  • Show me all the Models created before July 19, 2006:
    get-wfrecords admin | ?{$_.datemodified -lt (Get-Date “july 19, 2006”) -and $_.type -eq “model”} | Select-Object name, datemodified
  • Show me the models, processes, etc with Matt in the name:
    get-wfrecords admin | ?{$ -like “*Matt*”}

To get just one of these done in 15 lines of code in Visual Studio is pretty easy. But to get the many different variations I have in the same number is pretty freaking cool. Basically now I have to come up with methods to output all the different types of things in the system, then think about the different ways admins want to manipulate them. Do any of my readers have any ideas? Anything you want to see?

Find Matt online: