Fix XML corruption when creating scheduled tasks with --force flag #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I don't know if this project is maintained anymore, but I'll post it here in case anyone stumbles on it.
Currently,
SharpGPOAbusecorrupts theScheduledTasks.xmlfile when overwriting or appending a task using the--Forceflag. The bug happens on line 902:line = ImmediateTaskXML + lineThis prepends the new task at the absolute beginning of the file, even before the
<?xml ...?>header. This corrupts theScheduledTasks.xmlfile and causes an error on the client machines when fetching the new GPO. This is unfortunate, especially if you have only one GPO that you can take advantage of and don't want to run a scheduled task on all the machines linked to the GPO, meaning you are reliant on using the--FilterEnabledflag to filter for specific hosts and need to run the command multiple times.The fix is simple, just add the
ImmediateTaskXMLinside the<ScheduledTasks>tag. Now you can add multiple scheduled tasks using the--forceflag and even use the filtering to run different scheduled tasks on different targets.