Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Fixed
-
None
-
None
-
Windows 2012 and 2016 Standard
Puppet agent 1.10.7 x64
PowerShell 5.1.14393.1532
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 =>
,
}
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]@
| new-pscredential
}
ModuleName = @
}
try
{ $result = Invoke-DscResource @invokeParams }catch
{ $response.errormessage = $_.Exception.Message return ($response | ConvertTo-Json -Compress) }- 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:
;^\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