The PSEC package provides a set of routines that enhance PowerShell. They include:
Addition commands to supplement Powershell. See CMDS - Overview
A robust GUI system. See PSEC - GUI Capability
A comprehensive Workflow package based on the builtin GUI. See PSEC - Workflow Facility Overview
Restart facilities to aid in developing scripts and classes. See PSEC - Restart Facility
Themed icon and console management for multiple simultaneous PSEC applications. See PSEC - Icon and Console Management.
A built-in documentation system that builds what you are reading. See PSEC - Rebuilding Documentation
Working examples to use as a basis for custom Workflows or further development. See PSEC - Reference Examples
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
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.
{
"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.
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";
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, 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";
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.
A GUI configurator engine to build the Workflows. See PSEC - Workflow Configurator.
The PSEC distribution contains the complete source code so custom modifications can be made.
Copyright © 2018-2021, 2022, Rexcel System Inc.