Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-5623

DSC creating scheduled task fails after upgrading to 1.4.0

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: dsc
    • Environment:

      Windows 2012 and 2016 Standard
      Puppet agent 1.10.7 x64
      PowerShell 5.1.14393.1532

    • Template:
      MODULES Bug Template
    • Epic Link:
    • Team:
      Windows
    • Method Found:
      Needs Assessment
    • Zendesk Ticket IDs:
      41960
    • Zendesk Ticket Count:
      1
    • QA Risk Assessment:
      Needs Assessment

      Description

      Basic Info
      Module Version: puppetlabs-dsc 1.4.0
      Puppet Version: Agent: 1.10.7 x64 Server: 2.7.2-1el7
      OS Name/Version: Windows Server 2012 and 2016

      Describe your issue in as much detail as possible...
      Creating scheduled tasks with puppetlabs-dsc fails after upgrading to version 1.4.0:
      Basically the puppet complains that it cannot convert dsc_repeatinterval and dsc_starttime:

      • Error: /Stage[main]/Platform::Install::Cleanup_task/Dsc_xscheduledtask[Cleanup_task]: Could not evaluate: Convert property 'repeatinterval' value from type 'STRING' to type 'DATETIME' failed
        Once I disable dsc_repeatinterval I got:
      • Error: /Stage[main]/Platform::Install::Cleanup_task/Dsc_xscheduledtask[Cleanup_task]: Could not evaluate: Convert property 'starttime' value from type 'STRING' to type 'DATETIME' failed
        If I try to add dsc_daysofweek into the same scheduled task the server doesn't work:
        Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: no parameter named 'dsc_daysofweek'

      The scheduled task is:

      dsc_xscheduledtask { 'Cleanup_task':
      dsc_ensure => present,
      dsc_enable => true,
      dsc_taskname => 'Cleanup_task',
      dsc_actionexecutable => 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0
      powershell.exe',
      dsc_actionarguments => "-file ${scripts_path}
      Cleanup_script.ps1",
      dsc_scheduletype => 'daily',
      #dsc_repeatinterval => '1',
      #dsc_starttime => "03:24",
      #dsc_daysofweek => ['1','4'],
      dsc_executeascredential =>

      {'user' => "srv01\\adm_usr", 'password' => 'mypass' }

      ,
      }

      Desired Behavior:
      In version 1.3.1 of this module, the repeatinterval and starttime worked. dsc_daysofweek didn't work.

      Actual Behavior:
      Puppet agent fails to create a new scheduled task

      Please take a moment and attach any relevant log output and/or manifests. This will help us immensely when troubleshooting the issue.
      The output of the puppet agent -td for this issue can be found bellow. However if I copy the whole script into PowerShell ISE and place [datetime] in front of the starttime works.

      function new-pscredential

      { [CmdletBinding()] param ( [parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] [string] $user, [parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] [string] $password ) $secpasswd = ConvertTo-SecureString $password -AsPlainText -Force $credentials = New-Object System.Management.Automation.PSCredential ($user, $secpasswd) return $credentials }

      $response = @

      { indesiredstate = $false rebootrequired = $false errormessage = '' }

      $invokeParams = @{
      Name = 'xScheduledTask'
      Method = 'test'
      Property = @{
      taskname = 'Cleanup_task'
      actionexecutable = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
      actionarguments = '-file C:\Scripts\Cleanup_script.ps1'
      scheduletype = 'daily'
      starttime = '03:22'
      ensure = 'present'
      enable = $true
      executeascredential = [PSCustomObject]@

      {'user' = 'srv01\adm_usr'; 'password' = 'mypass'}

      | new-pscredential
      }
      ModuleName = @

      { ModuleName = "C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet_x/dsc_resources/xComputerManagement/xComputerManagement.psd1" RequiredVersion = "2.1.0.0" }

      }

      try

      { $result = Invoke-DscResource @invokeParams }

      catch

      { $response.errormessage = $_.Exception.Message return ($response | ConvertTo-Json -Compress) }
      1. keep the switch for when Test passes back changed properties
        switch ($invokeParams.Method) {
        'Test' { $response.indesiredstate = $result.InDesiredState return ($response | ConvertTo-Json -Compress) }

        'Set'

        { $response.indesiredstate = $true $response.rebootrequired = $result.RebootRequired return ($response | ConvertTo-Json -Compress) }

        }

      Debug: Waited 0.0 total seconds.
      Debug: Dsc Resource returned:

      {"rebootrequired":false,"indesiredstate":false,"errormessage":"Convert property \u0027starttime\u0027 value from type \u0027STRING\u0027 to type \u0027DATETIME\u0027 failed\r\n At line:21, char:2\r\n Buffer:\r\n1 0\\\\powershell.exe\";\n}

      ;^\n\ninsta\r\n"}

      Error: /Stage[main]/Platform::Install::Cleanup_task/Dsc_xscheduledtask[Cleanup_task]: Could not evaluate: Convert property 'starttime' value from type 'STRING' to type 'DATETIME' failed
      At line:21, char:2
      Buffer:
      1.0
      powershell.exe";
      };^

      insta

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            o.calbajos Ovidiu Calbajos
            Votes:
            1 Vote for this issue
            Watchers:
            12 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support