guitarrapc / GraniResource

PowerShell Desired State Configuration Resources for real production workload.
https://www.powershellgallery.com/packages/GraniResource
MIT License
44 stars 8 forks source link

cScheduleTask - The RepetitionInterval and RepetitionDuration Job trigger parameters must be specified together #73

Closed Zuldan closed 7 years ago

Zuldan commented 7 years ago

The config below for cScheduledTask worked perfectly fine in 3.7.8.1...

cScheduleTask PowershellHelpUpdateScheduledTask
{
    Ensure                           = 'Present'
    PsDscRunAsCredential             = $Credential
    TaskName                         = 'Powershell Help Update'
    Runlevel                         = 'Highest'
    Compatibility                    = 'Win8'
    Hidden                           = $False
    Disable                          = $False
    Execute                          = 'powershell.exe'
    Argument                         = "-NoProfile -Command `"Update-Help -SourcePath $($Node.PowershellHelpSource) -Module * -Force -ErrorAction SilentlyContinue`""
    TaskPath                         = '\'
    ScheduledAt                      = [DateTime]"2016/02/13 $($Time.Hour):$($Time.Minute):00" # Saturday
    RepetitionIntervalTimeSpanString = [TimeSpan]::FromDays(7).ToString() # run every week
    RepetitionDurationTimeSpanString = [TimeSpan]::MaxValue.ToString() # to forever
}

...but in 3.7.8.3 the following error appears...

Invoke-CimMethod : PowerShell DSC resource Grani_ScheduleTask  failed to execute Set-TargetResource functionality with error message: The RepetitionInterval and RepetitionDuration Job trigger parameters must be specified together. 
At C:\LabCode\Invoke-LabServer.ps1:20 char:5
+     Invoke-CimMethod -CimSession $ServerName -Name PerformRequiredCon ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Invoke-CimMethod], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
    + PSComputerName        : LABSERVER01
guitarrapc commented 7 years ago

What a shame. Checking....

https://github.com/guitarrapc/GraniResource/compare/ver.3.7.8.1...ver.3.7.8.3

guitarrapc commented 7 years ago

ok. Issue seems to be haapen when target OS is Windows Server 2012 R2 or lower. Will not happen on Windows Server 2016 and Win10.

Win2016 and Win10

VERBOSE: [WINDOWS10PRO]: LCM:  [ Start  Set      ]
VERBOSE: [WINDOWS10PRO]: LCM:  [ Start  Resource ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [WINDOWS10PRO]: LCM:  [ Start  Test     ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [WINDOWS10PRO]:                            [[cScheduleTask]PowershellHelpUpdateScheduledTask] False
VERBOSE: [WINDOWS10PRO]: LCM:  [ End    Test     ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]  in 1.4040 seconds.
VERBOSE: [WINDOWS10PRO]: LCM:  [ Start  Set      ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [WINDOWS10PRO]:                            [[cScheduleTask]PowershellHelpUpdateScheduledTask] Ensure detected as Present. Setting ScheduledTask for TaskPath '\', TaskName 'Powershell
 Help Update'.
VERBOSE: [WINDOWS10PRO]: LCM:  [ End    Set      ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]  in 0.6550 seconds.
VERBOSE: [WINDOWS10PRO]: LCM:  [ End    Resource ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [WINDOWS10PRO]: LCM:  [ End    Set      ]
VERBOSE: [WINDOWS10PRO]: LCM:  [ End    Set      ]    in  2.7420 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.89 seconds

And is due to change on ver.3.7.8.3 as Zuldan suspect.

@Zuldan To ensure issue, can you kindly clarify your Lab OS Version?

guitarrapc commented 7 years ago

@Zuldan I've fixed and publish ver.3.7.8.4 to PowerShell Gallery. https://www.powershellgallery.com/packages/GraniResource/3.7.8.4

It is appreciated if you can check at your lab.

Zuldan commented 7 years ago

@guitarrapc, thanks so much for getting it fixed so quickly. I'm using 2012 R2 in my lab. It's working now with version 3.7.8.4.