Managing platform schedules

This article describes how to use the 1E PowerShell Toolkit to manage 1E Platform schedules.

1E Platform schedules allow you to set up a schedule for an instruction to be run either once or on a regular basis. Optionally, you can specify a conditional evaluation script which is to be run server-side when the instruction has been run. You can specify whether the script should always run or only based on an evaluation of the row count returned by the instruction. For example, you can define that the conditional evaluation script should only run when the instruction returns more than 10 rows of data.

Platform schedules support a wide range of schedule options. For simplicity, the 1E PowerShell Toolkit supports a subset of these options.

Core scheduling concepts

When you specify a schedule, you can define the following:

  • How often the schedule should run (for example, daily, every 10 minutes, and so on).
  • Where the schedule is only triggered at most once in any day, the start time on which the schedule should be triggered.
  • Where the schedule is triggered multiple times in any day, the start time and end time between which the schedule should be triggered.
  • For schedules which trigger on a weekly or monthly basis, you can optionally define which day of the week or which week of the month the schedule should be triggered on.

Creating a schedule

You use the publish-1Escheduledtask cmdlet to create a schedule. 

As a minimum, you must specify the following:

  • The name of the instruction to be scheduled.
  • Values for any parameters for the instruction that do not already have defaults defined in the instruction.
  • The target scope for the instruction.
  • The schedule for the instruction.

For example:

Copy
publish-1Escheduledtask -InstructionName 1E-Explorer-TachyonAgent-Echo -Targetscope urth -Schedule Daily

If you do not specify a StartDate and EndDate parameter, then the schedule is assumed to start today and finish tomorrow.

For schedules that operate over a longer rescheduling period than a day, these defaults will cause the cmdlet to throw an exception, indicating that no schedule events would have taken place with the specified parameters.

You will need to provide additional parameters that define at least an appropriate end date for longer schedule periods (for example, weekly or monthly) to be created.

For a description of the full set of cmdlet parameters, refer to Platform server management cmdlets.

Schedule creation and workflow

The creation of a schedule requires workflow approval. In the example below, it is assumed that workflow has been set up for self-approval.

If workflow has been configured for normal approval by a separate approver, you will need to run the toolkit in two windows. You will need to be logged on as the initiator in one window and as the approver in the second window. You can use the Windows runas command to start new PowerShell sessions as a different user than your current logged-on identity. Alternatively, you can use the -Credential parameter to the set-1Eserver cmdlet to provide alternative credentials in a separate PowerShell window so that the session runs in the context of the approver account. You will then perform the approval in this second PowerShell session, rather than in a single session, as shown in the example below.

Publish the schedule

We will use the simple echo test instruction as the payload. Publish the schedule as a one-time schedule to start immediately.

Copy
Publish-1EScheduledTask 1E-Explorer-TachyonAgent-Echo -TargetScope urth -Schedule once -Msg scheduled

We will receive a workflow approval request via email.

Approve the schedule creation

Copy
Approve-1EInstruction -ScheduleId 81 -Token DJ1XD

Verify that the schedule has been invoked

It should appear in history as the most recent item, once the schedule trigger datetime is reached.

Copy
Get-1EInstructionHistory -itemcount 1

Currently, the schedule must be approved before its first trigger datetime is reached. If this is not done, the schedule may not be triggered.