PSEC - Powershell Enhanced Capability
Version 1.2.1

PSEC - Powershell Enhanced Capability

A set of additional functions for Powershell that includes a robust GUI API and a comprehensive Workflow facility

The PSEC package provides a set of routines that enhance PowerShell. They include:

  1. Addition commands to supplement Powershell. See CMDS - Overview

  2. A robust GUI system. See PSEC - GUI Capability

  3. A comprehensive Workflow package based on the builtin GUI. See PSEC - Workflow Facility Overview

  4. Restart facilities to aid in developing scripts and classes. See PSEC - Restart Facility

  5. Themed icon and console management for multiple simultaneous PSEC applications. See PSEC - Icon and Console Management.

  6. A built-in documentation system that builds what you are reading. See PSEC - Rebuilding Documentation

  7. Working examples to use as a basis for custom Workflows or further development. See PSEC - Reference Examples

PSEC Installer Download

A current version of PSEC installation can be obtained at the following location. The .exe is a self-extracting zip file that will guide you through the install process.

The zip file contains the Powershell source files, working examples and this documentation.

Note: The file is downloaded as a .bin file to avoid download complications in the browser. It should be renamed once downloaded by dropping the .bin suffix. If you have a virus scanner installed the rename process will trigger a local scan of the file.

The download can be obtained at: DOWNLOAD PSEC Installer EXE

Hello World Example

The ease of creating a Workflow in PSEC is shown by the following example.

It orchestrates the creation of a file that takes a long time followed by the processing of the file once it is created.

The command flow psec-hello in a PSEC window starts the orchestration.

The detailed explanation can be seen at PSEC Hello World Example.

The Configuration File
{
  "title": "PSEC Workflow Hello World Example",
  "tasks":  [
               {
                   "title":  "Create Data",
                   "lib":    "run-generic-script",
                   "alias":   "create-data",
                   "parm-sleep": 20,
                   "parm-msg": "Data created",
                   "parm-file": "psec-hello-world-demo-file.txt"
               },
               {
                   "title":  "Wait for data",
                   "lib":    "run-generic-script",
                   "alias":   "wait-data",
                   "dependsOn":"create-data"
               },
               {
                  "title":  "Process data",
                  "lib":    "run-generic-script",
                  "alias":   "process-data",
                  "dependsOn":"wait-data"
               }
           ]
}

See Sample NAME-cfg.json Format for the parameter description of this file.

Step 1 Create File Script

Running Step 1 creates a file after a configured delay.

The file name is calculated from the task location and the configured name. It is passed to the subsequent steps in a global hashmap provided by the PSEC Workflow infrastructure.


param([Task]$task,[hashtable]$cfgParms,[hashtable]$brief)

$targFile = "$($task.execLocn)/$($cfgParms['file'])"
$sleepSecs = $cfgParms['sleep']
$task.tfs.globMap.creFile = $targFile;

$msg = "creating $targFile after $sleepSecs secs"
Remove-Item -Path $targFile -force


Start-Job -ScriptBlock {
  start-sleep $using:sleepSecs
  Set-Content -Path $using:targFile -Value $using:msg
  $wshell = New-Object -ComObject Wscript.Shell
  $Output = $wshell.Popup($using:msg)
}

$brief.createMsg = $msg
"$msg`r`nfinished`r`n";
Step 2 Wait File Script

Running Step 2 generates a FAIL or GOOD status depending on whether the file creation has completed.

param([Task]$task,[hashtable]$cfgParms,[hashtable]$brief)

$targFile = $task.tfs.globMap.creFile;
if (test-path $targFile) {
  $brief.sCondCode = "GOOD"
  $brief.waitMsg = "$targFile found"
} else {
  $brief.sCondCode = "FAIL"
  $brief.waitMsg = "$targFile not yet located"
}
"wait-data-run.ps1 finished`r`n";
Step 3 Process File Script

Step 3, the file processing step, is prevented from running until Step 2 has succeeded.

param([Task]$task,[hashtable]$cfgParms,[hashtable]$brief)

$targFile = $task.tfs.globMap.creFile;
$brief.procMsg = "$targFile ready for processing"
"process-data-run.ps1 finished`r`n";
Workflow Interface After Create File Initiated

Note that the top left shows the state of the 3 Steps and the main panel has more information concerning the state of the current task.

Workflow Interface After Wait File Fails
Workflow Interface After Wait File Succeeds, Process File not yet run
Workflow Interface After Process File Succeeds

Planned Enhancements

A GUI configurator engine to build the Workflows. See PSEC - Workflow Configurator.

Source Code Included

The PSEC distribution contains the complete source code so custom modifications can be made.

PSEC - Powershell Enhanced Capability
1.2.1

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

 

 

 

 

 

X