PSEC - Powershell Enhanced Capability
Version 1.2.1

Workflow Setup File


The setup file is executed when the Workflow is first loaded.

Its primary job is to populate the specific [TaskFlowStruc] $tfs variable with a custom global structure used to pass and preserve information related to the specific workflow.


The functions are called after the Flow object has been created and before any Task objects have been created.

psecFlowSetup Function

The function psecFlowSetup([Flow]$flow) function should populate the $flow.tfs.globMap hashmap with one or more global objects.

customTitle Function

The function customTitle([Flow]$flow,[Task]$task,[string]$title) is called whenever a Task is changed. It can be used to change the Window Title so that the user can quickly see specific context information (such as what month) the system globals are set to.

Example Setup File

The file shown here is used in the psec-demo flow that is part of the PSEC distribution package.

The DemoGlobal is the customized object that all tasks share. They use $flow.tfs.globMap.demoGlobs or $task.tfs.globMap.demoGlobs to locate it. The variable demoGlobs can be any name. More than one object could be created.

#psec-demo-setup.psm1  - Initalize psec-demo glow

set-strictmode -version 2.0

class DemoGlobal {
  [int32]  $cycleNo;
  [string] $month;
  [string] $excelRun;
  DemoGlobal() {
    $this.cycleNo = 1;
    $this.month = "jan";
    $this.excelRun = "?";

  function defineSetupFunction() {
  #--- define
  $def = new-module -asCustomObject -scriptBlock {
    # ---------- run setup, return cust object
    function psecFlowSetup([Flow]$flow) {
      $flow.tfs.globMap.demoGlobs = [DemoGlobal]::new();
      hlogBoth("----------- psec-demo-setup.psm1 specific setup called ---------------");

    # return a custom title optional. useful if context setter.
    function customTitle([Flow]$flow,[Task]$task,[string]$title) {
      $tfs = $flow.tfs;
      $extra = "$([char]0xa0)$([char]0xa0)$([char]0xa0)$([char]0xa0) --     cycleNo=$($tfs.globMap.demoGlobs.cycleNo) month=$($tfs.globMap.demoGlobs.month)"
      return "$($title) $extra"

    Export-ModuleMember -Variable * -Function *

  return $def;
PSEC - Powershell Enhanced Capability

Copyright © 2018-2021, 2022, Rexcel System Inc.