DSC – schedules task

Welcome Forums DSC (Desired State Configuration) DSC – schedules task

Viewing 1 reply thread
  • Author
    Posts
    • #246330
      Participant
      Topics: 1
      Replies: 0
      Points: 13
      Rank: Member

      Hello all,

       

      I would like to used DSC to create some scheduled task.

       

      I arrive to create some schedule task with .mof file but I would like to generate an .mof file since a .csv file.

       

      Configuration Example
      {
      param
      (
      [Parameter()]
      [System.String[]]
      $NodeName = ‘localhost’
      )

      Import-DscResource -ModuleName ComputerManagementDsc

      Node $NodeName
      {

      $import = import-csv -path c:\temp\sctask.csv -delimiter “;”

       

      foreach ($lineimport in $import$

      {
      ScheduledTask ScheduledTaskOnceAdd
      {
      TaskName = ‘$lineimport.TaskName’
      TaskPath = “\”+’$lineimport.TaskPath’
      ActionExecutable = ‘$lineimport.ActionExecutable’
      ScheduleType = ‘$lineimport.ScheduleType’
      RepeatInterval = ‘$lineimport.RepeatInterval’
      RepetitionDuration = ‘$lineimport.RepetitionDuration’
      ExecutionTimeLimit = ‘$lineimport.ExecutionTimeLimit’
      ActionWorkingPath = $lineimport.PathActionWorkingPath
      Enable = $true
      RandomDelay = ‘$lineimport.RandomDelay’
      DisallowHardTerminate = $true
      RunOnlyIfIdle = $false
      Priority = 9
      }
      }

      }

      }

       

      thank you for your help

    • #246594
      Senior Moderator
      Topics: 9
      Replies: 1366
      Points: 5,029
      Helping Hand
      Rank: Community MVP

      You have to name the configuration unique, something like

      you cannot use single quotes to wrap variables and to access property of an object inside double quotes, a sub expression $() has to be used.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.