mkellerman / Invoke-CommandAs

Invoke Command As System/Interactive/GMSA/User on Local/Remote machine & returns PSObjects.
https://www.powershellgallery.com/packages/Invoke-CommandAs/
MIT License
455 stars 71 forks source link

Update Invoke-ScheduledTask.ps1 #50

Closed hartleyj closed 4 years ago

hartleyj commented 4 years ago

Updated Invoke-ScheduledTask.ps1 to add "-StartIfOnBattery -ContinueIfGoingOnBattery" parameters to New-ScheduledJobOption

Default behavior of scheduled tasks is to start when on AC power, causing Invoke-CommandAs to silently fail when run on a system running on battery power.

Added 'StartIfOnBattery' to allow scheduled tasks to run when on battery power, and 'ContinueIfGoingOnBattery' to allow for long-running script blocks to continue running after transitioning from AC to battery power.

mkellerman commented 4 years ago

Tempted to say that this should be a default behaviour, and switch options to disable those. I’d expect the command to run, by default, regardless of battery state.

hartleyj commented 4 years ago

Agreed. This PR changes the default behavior.

No allowances are made for changing this new default with a switch option, however.