Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Ability to export scheduled tasks from Windows Task Scheduler to json. #1

Open
WestXu opened this issue Sep 17, 2020 · 3 comments
Labels
feature good first issue Good for newcomers

Comments

@WestXu
Copy link

WestXu commented Sep 17, 2020

Great project!

Now that we have a function Setup-ScheduledTask to import tasks from json to Scheduler, it'll be great to have a reverse function to Export-ScheduledTask from Scheduler to same-format json, with all default settings omitted. Just like the official builtin one. Cause apperarently its format of xml is not compatible with this project, and it's output is way too redundant with all settings (event default) exported.

Then I can build up a git-tracked tasks configuration workflow: just Export all my current tasks to a json file for the frist time, include it in a git repo, and whenever I make a change, I can just run a script to delete all my tasks and re-Setup all over again.

@leojonathanoh
Copy link
Member

@WestXu

If I understand you correctly, you want to export Scheduled Tasks from Windows Task Scheduler to have Task objects source-controlled in a git repo that follow the spec of the Task Objects used in this project which are really just arguments to parameters of some of the Scheduled Tasks related Powershell Cmdlets.

Like you said, one reason this feature would be useful for those who want to begin to source-control simpler Task using our this project's Task spec. Another reason I can think of is that there is no inbuilt Import-ScheduledTask cmdlet so using the native Export-ScheduledTask is really just making a XML backup which has to be restored to Task Scheduler via the GUI. In contrast, our version of Export-ScheduledTask only has to be run once by a user to serialize those tasks as JSON documents, and supports non-interactive setting up of scheduled tasks based on the JSON Task objects.

If we are going to create this serializer, we are going to have to parse all Task Objects returned by Get-ScheduledTasks, and convert each task to this spec, and finally serializing this to a JSON or YAML which can be source-controlled in a git repo.

@leojonathanoh leojonathanoh added good first issue Good for newcomers enhancement New feature or request labels Sep 18, 2020
@WestXu
Copy link
Author

WestXu commented Sep 18, 2020

@leojonathanoh

That's exactly what I meant. Hopefully this won't be too much work. If only I know how to code in ps to be of help.

@leojonathanoh
Copy link
Member

@WestXu this will require some work, but it shouldn’t be too tough. One thing if I recall rightly, is that we might have some trouble with converting schedules in the Task Scheduler which are supported by schtasks.exe with /SC flag but there is no flag for monthly schedule for New-ScheduledTaskTrigger. Small inconsistencies might make converting the Task schedule a more challenging.

@joeltimothyoh joeltimothyoh added feature and removed enhancement New feature or request labels Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants