- Users might be interested in automatically receiving reports about the JS7 - Daily Plan which list the scheduled workflows and the date and time when they are executed.
- Such reports include similar information to that which is available in the JOC Cockpit's Daily Plan view.
- The reports are provided as Excel® files similar to those which are available for export from the JOC Cockpit Daily Plan view.
- These reports can be scheduled, for example on a daily basis, to provide ongoing information about completed orders and timed orders for workflow execution.
Report the Daily Plan from a Job
Daily Plan reports can be automated by by JS7 jobs. The following PowerShell modules are used for this purpose:
- JS7 PowerShell Module to access the JS7 - REST Web Service API.
- ImportExcel PowerShell Module (3rd party) to create Excel® reports on Windows and Linux.
The Get-JS7DailyPlanOrder cmdlet is used to retrieve Daily Plan items and to forward them to the ImportExcel module within a job. The job is the same for Windows and Unix.
Find a sample report for download that includes the report with its Daily-Plan worksheet: jobscheduler_reporting.xlsx
First Line of the Job
The only difference between platforms is the way how PowerShell is invoked with the first line of the job.
- Use of a shebang allows to invoke the
- Credits for the Windows shebang replacement to How to run a PowerShell script within a Windows batch file.
- If you consider this shebang replacement somewhat cryptic then add it to JS7 - Script Includes that are easily referenced from a shell job, for example by using
- The PowerShell executable
pwsh.exeis available starting from PowerShell 6.0. PowerShell releases 5.x use the executable
powershell.exethat can be specified accordingly with the shebang.
Please note that the job listed below is an example which has to be modified for your environment.
- Line 1: The job is executed with a Windows Agent and uses the PowerShell shebang for Windows, as explained above.
- Line 3-4: The required PowerShell modules are imported. They could be installed at any location in the file system
- Line 6-7: The Connect-JS7 cmdlet is used to authenticate with the JS7 REST Web Service API. The required arguments for
-Idcan specified in a number of ways:
- As described in the JS7 - How to connect to JOC Cockpit using the PowerShell Module article.
- Using JS7 - Job Resources which inject environment variables to the PowerShell job.
- Using a PowerShell profile.
- Line 10: For better readability of the report the start types of jobs are mapped to a textual representation (single start, cyclic start etc.).
- Line 13: The Get-JS7DailyPlanOrder cmdlet is invoked
- with the
-Timezoneparameter to specify which time zone date values in the report should be converted to. The
-Timezone (Get-Timezone)parameter value specifies that the time zone of the Agent's server is used. Otherwise the desired time zone can be specified, for example like this:
-Timezone (Get-Timezone -Id 'GMT Standard Time').
- When this parameter is not specified then any date values will be stored in the report as UTC dates.
- optionally with additional parameters, for example to specify the date or date range which the report is being created for. A value
-RelativeDateTo +7dspecifies that the report should cover the next 7 days (until midnight). Keep in mind that dates have to be specified for the UTC time zone. Without this parameter the report will be created for the next day.
- see the Get-JS7DailyPlanOrder cmdlet for a full parameter reference.
- with the
- Line 14-26: From the output of the
Get-JS7DailyPlanOrdercmdlet a number of properties are selected and and are specified for the sequence in which they should occur in the report.
- To add more appropriate column headers the property names are mapped to a more readable textual representation.
- Note the handling of date formats in line 21-25. Use of the
Get-Datecmdlet converts the output format of dates (not the time zone) to the default format that is in place on the Agent's server. Without using the
Get-Datecmdlet any date values will be stored in the report in ISO format, e.g.
2020-12-31 10:11:12+02:00for a date in the European central time zone which is UTC+1 in winter time and UTC+2 in summer time.
- Lines 23, 26 introduce a new property, a calculated duration. This is the difference in seconds between the start time and end time values of a planned start and optionally of a past start, which is calculated and forwarded to the report.
- Line 27: The list of properties per Daily Plan item is piped to the
Export-Excelcmdlet which is available with the ImportExcel PowerShell Module. The report file name is specified and optionally the worksheet. For a full list of parameters see the ImportExcel PowerShell Module.