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

ScheduledTask: MultipleInstances Parameter Should Allow For 'StopExisting' #333

Closed
Rob-S opened this issue May 12, 2020 · 1 comment
Closed
Labels
bug The issue is a bug.

Comments

@Rob-S
Copy link
Contributor

Rob-S commented May 12, 2020

Details of the scenario you tried and the problem that is occurring

In this case, we have a scheduled task that runs continuously but gets restarted daily, The manually created tasks specify "If the scheduled task is already running, then ... Stop the existing instance". This is one of four options in the drop-down box and shows up in the task's XML file as:

  <Settings>
    <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>

Verbose logs showing the problem

ComputerManagementDsc\ScheduledTask : At least one of the values 'StopExisting' is not supported or valid for property 'MultipleInstances' on class 'ScheduledTask'. Please specify only supported values: 
IgnoreNew, Parallel, Queue.
At C:\Git-Repositories\dba\dsc\sbcdb-sync\Compile-TaskSchedulerConfiguration.ps1:43 char:7
+       ScheduledTask 'MonitorTask'
+       ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnsupportedValueForProperty,ComputerManagementDsc\ScheduledTask

Suggested solution to the issue

Add "StopExisting" to the list of valid values for the MultipleInstances parameter.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

      ScheduledTask 'PSTask'
      {
         TaskName                         = 'pstask'
         TaskPath                         = '\'
         ActionExecutable                 = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
         ActionArguments                  = "-File `"C:\ps\myps.ps1`""
         ActionWorkingPath                = 'C:\ps'
         ScheduleType                     = 'Daily'
         RepeatInterval                   = '00:00:00'
         StartTime                        = '00:00:00.000' 
         SynchronizeAcrossTimeZone        = $false 
         Ensure                           = 'Present'
         Enable                           = $true
#         ExecuteAsCredential              = $ExecuteAs 
         DaysInterval                     = 1 
         RandomDelay                      = '00:00:00' 
         RepetitionDuration               = 'Indefinitely'
         WeeksInterval                    = 1 
         DisallowDemandStart              = $false
         DisallowHardTerminate            = $false
         AllowStartIfOnBatteries          = $true 
         Hidden                           = $false
         RunOnlyIfIdle                    = $false
         DisallowStartOnRemoteAppSession  = $false
         StartWhenAvailable               = $true
         DontStopIfGoingOnBatteries       = $true 
         WakeToRun                        = $true 
         RestartOnIdle                    = $false 
         DontStopOnIdleEnd                = $true
         ExecutionTimeLimit               = '00:00:00'
         MultipleInstances                = 'StopExisting'
         Priority                         = 0 
         RestartCount                     = 3 
         RestartInterval                  = '00:05:00'
         RunOnlyIfNetworkAvailable        = $false 
         RunLevel                         = 'Highest'
         LogonType                        = 'ServiceAccount'
      }

The operating system the target node is running

Version and build of PowerShell the target node is running

Version of the DSC module that was used ('dev' if using current dev branch)

ComputerManagementDsc 8.2.0

Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue May 13, 2020
@PlagueHO PlagueHO added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. needs investigation The issue needs to be investigated by the maintainers or/and the community. labels May 13, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 10, 2020
PlagueHO added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 14, 2020
…pleInstances-Parameter-Should-Allow-For-'StopExisting'
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 17, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 17, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 17, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 17, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 17, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 18, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 19, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 19, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 19, 2020
Rob-S added a commit to Rob-S/ComputerManagementDsc that referenced this issue Jun 26, 2020
@PlagueHO PlagueHO removed help wanted The issue is up for grabs for anyone in the community. needs investigation The issue needs to be investigated by the maintainers or/and the community. labels Jun 26, 2020
@PlagueHO
Copy link
Member

Closing as addressed in #339

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants