ComputerManagementDsc icon indicating copy to clipboard operation
ComputerManagementDsc copied to clipboard

xScheduledTask: Add multiple ScheduleTypes

Open jamesmealing opened this issue 8 years ago • 8 comments

Unless I'm missing something really obvious (entirely possible!) I can't seem to find a way to add multiple ScheduleTypes (Triggers) to new Scheduled Tasks. For example, a task that recurs daily, but also runs at computer startup. I have tried specifying multiple schedule types as a comma separated list, and also running a second instance of xScheduledTask to "amend" the new task with an additional Schedule/Trigger, however neither of these seem to work. Is this possible at all, or alternatively can it be made possible?

jamesmealing avatar Jul 14 '17 16:07 jamesmealing

Hi @jamesmealing - that is a really good question.

Unfortunately with the way the resource is designed it isn't possible to set multiple schedule types for each scheduled task.

The only way to currently do this is to create two completely separate tasks with the same task actions, but with a different schedule. This isn't the most elegant and of course means that you'd need to check two different logs to see what was run.

The way to fix this in future is to break this resource up into three separate resources:

  1. xScheduledTaskEx (that creates the task with no actions or schedules)
  2. xScheduledTaskAction (creates an action against a task).
  3. xScheduledTaskSchedule (creates a schedule against a scheduled task).

This is an example of a resource that sacrifices flexibility to gain simplicity. So adding the above resources would make your requirement possible - but it will take some time.

PlagueHO avatar Jul 17 '17 20:07 PlagueHO

+1

I feel having multiple schedule types would be a great addition. I've hit the need for this myself.

Just to call out, xFirewall uses a string array to allow multiple values for a few settings: https://github.com/PowerShell/xNetworking/wiki/xFirewall

Although, I'm willing to concede to the fact that the effort to refactor may not be worth the end-value.

mrpeanutbutta avatar Nov 20 '17 17:11 mrpeanutbutta

This issue has been automatically marked as stale because it has not had activity from the community in the last 30 days. It will be closed if no further activity occurs within 10 days. If the issue is labelled with any of the work labels (e.g bug, enhancement, documentation, or tests) then the issue will not auto-close.

stale[bot] avatar Jun 16 '18 22:06 stale[bot]

This is still outstanding. Would it be possible for someone to add the "enhancement" label to this, to prevent it from auto-closing? (I might try and take a look at implementing this soon if I can...)

jamesmealing avatar Jun 18 '18 09:06 jamesmealing

@jamesmealing I have labeled it as enhancement.

/cc @PlagueHO

johlju avatar Jun 18 '18 10:06 johlju

Thumbs up from me on this one. Investigating using this to manage a large number of scheduled tasks, unfortunately most tasks have multiple daily triggers so this currently wouldn't be a suitable way of doing it.

TheDotSource avatar Jun 03 '21 14:06 TheDotSource

+1 on this.

bryansoemo avatar Sep 20 '22 21:09 bryansoemo

+1 (need this too)

TomTomLostInCode avatar May 03 '24 16:05 TomTomLostInCode