dsccommunity / ComputerManagementDsc

DSC resources for for configuration of a Windows computer. These DSC resources allow you to perform computer management tasks, such as renaming the computer, joining a domain and scheduling tasks as well as configuring items such as virtual memory, event logs, time zones and power settings.
https://dsccommunity.org
MIT License
300 stars 83 forks source link

ScheduledTask: NOTMATCH when using SynchronizeAcrossTimeZone #374

Open shurick81 opened 3 years ago

shurick81 commented 3 years ago

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

Trying to run the task in the specific time according to the local time zone (Stockholm) with daylight saving. Start-DscConfiguration works without issues. Test-DscConfiguration however, throws an error and returns ResourcesNotInDesiredState.

If I try with SynchronizeAcrossTimeZone = $false the code is executing without errors but then it looks like startup time is not corrected according to daylight saving.

If I keep SynchronizeAcrossTimeZone = $false but disable daylight saving on the target node, it is also executing without errors.

Verbose logs showing the problem

VERBOSE: [SWAZDB00]: LCM:  [ Start  Compare  ]
VERBOSE: [SWAZDB00]: LCM:  [ Start  Resource ]  [[ScheduledTask]CubeDefinitionDeployment]
VERBOSE: [SWAZDB00]: LCM:  [ Start  Test     ]  [[ScheduledTask]CubeDefinitionDeployment]
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] Testing scheduled task
'Automatisk uppdatering av kubdefinitioner' in '\'.
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] Getting current scheduled
task values for task 'Automatisk uppdatering av kubdefinitioner' in '\'.
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] Task 'Automatisk uppdatering
av kubdefinitioner' found in '\'. Retrieving settings, first action, first trigger and repetition settings.
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] Detected schedule type
'Daily' for first trigger.
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] Current scheduled task values
 for task 'Automatisk uppdatering av kubdefinitioner' in '\' retrieved.
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] Testing DSC parameter state.
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] NOTMATCH: Value (type
'System.String') for property 'StartTime' does not match. Current state is '2021-01-01T05:45:00+02:00' and desired
state is '2021-01-01T06:45:00+02:00'. (DRC0021)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.Boolean') for property 'SynchronizeAcrossTimeZone' does match. Current state is 'True' and desired state is
'True'. (DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.String') for property 'ActionExecutable' does match. Current state is
'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' and desired state is
'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'. (DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.String') for property 'ExecuteAsCredential' does match. Current state is 'C0NT0S00\_testuser1' and desired
state is 'C0NT0S00\_testuser1'. (DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.String') for property 'TaskPath' does match. Current state is '\' and desired state is '\'. (DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.UInt32') for property 'DaysInterval' does match. Current state is '1' and desired state is '1'. (DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.String') for property 'ActionWorkingPath' does match. Current state is
'C:\AutomatiskUppdateringKubdefinitioner\Test' and desired state is 'C:\AutomatiskUppdateringKubdefinitioner\Test'.
(DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.String') for property 'ScheduleType' does match. Current state is 'Daily' and desired state is 'Daily'.
(DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] MATCH: Value (type
'System.String') for property 'TaskName' does match. Current state is 'Automatisk uppdatering av kubdefinitioner' and
desired state is 'Automatisk uppdatering av kubdefinitioner'. (DRC0020)
VERBOSE: [SWAZDB00]:                            [[ScheduledTask]CubeDefinitionDeployment] Test-DscParameter result is
'False'. (DRC0026)
VERBOSE: [SWAZDB00]: LCM:  [ End    Test     ]  [[ScheduledTask]CubeDefinitionDeployment] False in 0.2500 seconds.
VERBOSE: [SWAZDB00]: LCM:  [ End    Resource ]  [[ScheduledTask]CubeDefinitionDeployment]
VERBOSE: [SWAZDB00]: LCM:  [ End    Compare  ]     Completed processing compare operation. The operation returned
False.
VERBOSE: [SWAZDB00]: LCM:  [ End    Compare  ]    in  0.3590 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.

Suggested solution to the issue

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

        ScheduledTask CubeDefinitionDeployment
        {
            TaskName                    = 'Automatisk uppdatering av kubdefinitioner'
            ActionExecutable            = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
            ActionWorkingPath           = $env:SSAS_SCHEDULED_TASK_DIR
            ScheduleType                = 'Daily'
            StartTime                   = '2021-01-01T05:45:00'
            SynchronizeAcrossTimeZone   = $true
            ExecuteAsCredential         = $SsasScheduledTaskCredential
            DaysInterval                = 1
        }

The operating system the target node is running

OsName               : Microsoft Windows Server 2016 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsBuildLabEx    : 14393.4402.amd64fre.rs1_release.210426-1725
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Version and build of PowerShell the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.14393.4402
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.4402
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

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

8.4.0