Ecometry PowerShell Execution Method Using A Template


A custom Ecometry Execution Method can be created to utilize PowerShell and a Template within the Execution Method to fetch the contents of an Ecometry SpoolOut File to pull into a JAMS Job log.

The Execution Method is based on the PowerShell Execution Method. To create an Execution Method, click on the Add button from within the Execution Method Shortcut.

Select PowerShell as a base Method and complete the creation process using the remaining default values.  

Check the box to Edit the Execution Method after you're Finished. Next, under the Execution Tab in the Options Field, input: ERRORSUMMARY,PASSPARAMS

Copy and Paste the following script within the Template Tab

#Get a temporary file 
$jobsourcefilename = [System.IO.Path]::GetTempFileName()
$jobexecutionfilename = [System.IO.Path]::GetTempFileName()

# Write the JAMS source to a temporary file
'@ > $jobsourcefilename

#Call Ecometry's cronsched with the STREAMFile parameter
C:\ECOMETRY\LIVECODE\PRO\cronsched.exe $jobsourcefilename ECOMLIVE 31000 C:\ECOMETRY\LISTENER\ecomlive.INI > $jobexecutionfilename

#Get the contents of the entire file into a string

$Contents = [io.file]::ReadAllText($jobexecutionfilename)

#Display the contents

$dir = "C:\ecometry\ecomlive\spoolout"
$latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
Get-Content $dir\$latest

# Cleanup
remove-item $jobsourcefilename -confirm:$false

Lastly, create a new Job using the EcometryPS Method and paste an Ecometry Script into the Source Tab of the Job as seen below:

Have more questions? Submit a request