Closed SAERXCIT closed 3 years ago
Thanks for your PR. I think there is an easier way to handle this. I already know how to implement it, I just need to find the time to work on this. 🙂
Done! 🙂
My solution is very simple. I iterate the Actions
list, and for each item, I create a completely new Task
object.
As a result, a Task
that has more than one Exec
Action
will appear several times in the final list with the same Name
.
A Task
with, let's say 2 command lines, will therefore be treated as 2 different Task
objects.
But that's not an issue at all.
Hi!
As discussed in issue #8, I tried implementing a solution to the multiple
<Exec>
entries problem forGet-ScheduledTaskList
.The element
Command
of typeString
becameCommands
of typeSystem.Collections.ArrayList
, which is a breaking change for projects operating on this output.I also had to change the checks operating on the output of
Get-ScheduledTaskList
, basically adding aForEach-Objects
on theCommands
element and creating a newPSObject
from scratch instead of adding elements to theCurrentTask
object. This has the benefit of correcting a bug happening when multiple results exist for the same task: the firstAdd-Member
s work as expected, but furtherAdd-Member
s for subsequent results of the sameCurrentTask
do not work, as the functionAdd-Member
does not allow overwriting by default. This results in theModifiablePath
,IdentityReference
, andPermissions
elements not being updated (and errors in the console), which for the user means the same result is outputted multiple times.In any case if you chose not to merge this PR, can you please add the
-Force
option to theseAdd-Member
s so that their value is updated for subsequent results of the same task.Cheers! :upside_down_face: