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

xScheduledTask ExecutionTimeLimit = '00:00:00' sets ExecutionTimeLimit to 3 days #115

Closed
GenericUserbame opened this Issue Nov 18, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@GenericUserbame

GenericUserbame commented Nov 18, 2017

Details of the scenario you tried and the problem that is occurring:
I'm trying to set scheduled task to no time execution limit; ExecutionTimeLimit = '00:00:00'
Doing this sets the execution time limit to 3 days.

This snippet was taken after deployment.
image

The DSC configuration that is using the resource (as detailed as possible):
xScheduledTask DeploymentTask
{
Ensure = "Present"
Enable = $true
TaskName = $Node.TaskName
ActionExecutable = "exe"
ActionArguments = "args"
ActionWorkingPath = "path"
ScheduleType = 'Daily'
StartTime = [datetime]::Now.AddMinutes($Node.TaskIntervalMinutes)
MultipleInstances = "IgnoreNew"
ExecutionTimeLimit = '00:00:00'
RepeatInterval = '00:15:00'
RepetitionDuration = 'Indefinitely'
}

Version of the Operating System and PowerShell the DSC Target Node is running:
Server 2016

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
3.1.0.0

@GenericUserbame

This comment has been minimized.

Show comment
Hide comment
@GenericUserbame

GenericUserbame Dec 5, 2017

master branch

Are you folks able to repro this on server 2016?

GenericUserbame commented Dec 5, 2017

master branch

Are you folks able to repro this on server 2016?

@PlagueHO

This comment has been minimized.

Show comment
Hide comment
@PlagueHO

PlagueHO Dec 6, 2017

Collaborator

Hi @ahebert - I've tried this on Windows Server 2016 and can confirm you are correct. Setting an execution time limit of '00:00:00' will set the time to 3 days. Not setting the parameter at all results in an execution time limit of 8 hours (the default value for the parameter when not set).

This actually has a really simple fix:
Change line:
https://github.com/PowerShell/xComputerManagement/blob/dev/DSCResources/MSFT_xScheduledTask/MSFT_xScheduledTask.psm1#L918
from:

if ($ExecutionTimeLimit -gt [System.TimeSpan] '00:00:00')

to:

if ($PSBoundParameters.ContainsKey('ExecutionTimeLimit'))

I have confirmed that this change will resolve the issue. I'll need to create some tests for this (which is actually the largest part of the change). So I'll get this done tomorrow night (running out of time tonight).

Collaborator

PlagueHO commented Dec 6, 2017

Hi @ahebert - I've tried this on Windows Server 2016 and can confirm you are correct. Setting an execution time limit of '00:00:00' will set the time to 3 days. Not setting the parameter at all results in an execution time limit of 8 hours (the default value for the parameter when not set).

This actually has a really simple fix:
Change line:
https://github.com/PowerShell/xComputerManagement/blob/dev/DSCResources/MSFT_xScheduledTask/MSFT_xScheduledTask.psm1#L918
from:

if ($ExecutionTimeLimit -gt [System.TimeSpan] '00:00:00')

to:

if ($PSBoundParameters.ContainsKey('ExecutionTimeLimit'))

I have confirmed that this change will resolve the issue. I'll need to create some tests for this (which is actually the largest part of the change). So I'll get this done tomorrow night (running out of time tonight).

@PlagueHO PlagueHO added in progress and removed help wanted labels Dec 7, 2017

@GenericUserbame

This comment has been minimized.

Show comment
Hide comment
@GenericUserbame

GenericUserbame Dec 7, 2017

Great, thanks for the follow-up. I'll make this change locally.

GenericUserbame commented Dec 7, 2017

Great, thanks for the follow-up. I'll make this change locally.

@PlagueHO

This comment has been minimized.

Show comment
Hide comment
@PlagueHO

PlagueHO Dec 7, 2017

Collaborator

@ahebert - I'm just completing the changes to the automated tests for this one now and will submit the PR in a little bit. But it might take a little bit to get merged into Dev depending on who is available for review.

Collaborator

PlagueHO commented Dec 7, 2017

@ahebert - I'm just completing the changes to the automated tests for this one now and will submit the PR in a little bit. But it might take a little bit to get merged into Dev depending on who is available for review.

@PlagueHO

This comment has been minimized.

Show comment
Hide comment
@PlagueHO

PlagueHO Dec 7, 2017

Collaborator

While making this change I found that the behaviour of ExecutionTimeLimit is different on Windows Server 2012 R2 and Windows Server 2016:

On Windows Server 2012 R2:
You need to create the settings object and then manually set the ExecutionTimeLimit to 'PT0S'
E.g.

$settings = New-ScheduledTaskSettingsSet
$settings.ExecutionTimeLimit = 'PT0S'

On Windows Server 2016:
You need to create the settings object and pass in a timespan string of '00:00:00' to the -ExecutionTimeLimit parameter:
E.g.

$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit '00:00:00'

So this took a bit longer than expected - but hopefully if anyone else is looking into this issue they'll find this info.

Collaborator

PlagueHO commented Dec 7, 2017

While making this change I found that the behaviour of ExecutionTimeLimit is different on Windows Server 2012 R2 and Windows Server 2016:

On Windows Server 2012 R2:
You need to create the settings object and then manually set the ExecutionTimeLimit to 'PT0S'
E.g.

$settings = New-ScheduledTaskSettingsSet
$settings.ExecutionTimeLimit = 'PT0S'

On Windows Server 2016:
You need to create the settings object and pass in a timespan string of '00:00:00' to the -ExecutionTimeLimit parameter:
E.g.

$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit '00:00:00'

So this took a bit longer than expected - but hopefully if anyone else is looking into this issue they'll find this info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment