You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Details of the scenario you tried and the problem that is occurring
When using the delay property for any schedule type other than OnEvent, the property is never set in the scheduled task. This causes the test to always fail and the set to always run.
scheduletype = 'AtLogOn'
delay = '00:00:30'
Verbose logs showing the problem
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = Resourcetest,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName'
= root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer REDACTED with user sid SID REDACTED.
VERBOSE: [REDACTED]: LCM: [ Start Test ] [[ScheduledTask]DirectResourceAccess]
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] Testing scheduled task 'OneDrive Mapper' in '\'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] Getting scheduled task 'OneDrive Mapper' in '\'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] Task 'OneDrive Mapper' found in '\'. Retrieving settings, first action, fi
rst trigger and repetition settings.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] Detected schedule type 'AtLogon' for first trigger.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] Current scheduled task values retrieved.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] Testing DSC parameter state.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] TEST Verbose
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] MATCH: Value (type 'String') for property 'ActionExecutable' does
match. Current state is 'C:\OneDrive_Mapper\OneDrive_Mapper.exe' and desired state is 'C:\OneDrive_Mapper\OneDrive_Mapper.exe'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] MATCH: Value (type 'String') for property 'LogonType' does match.
Current state is 'ServiceAccount' and desired state is 'ServiceAccount'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] MATCH: Value (type 'String') for property 'TaskPath' does match.
Current state is '\' and desired state is '\'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] MATCH: Value (type 'String') for property 'TaskName' does match.
Current state is 'OneDrive Mapper' and desired state is 'OneDrive Mapper'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] MATCH: Value (type 'Boolean') for property 'Enable' does match. C
urrent state is 'True' and desired state is 'True'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] NOTMATCH: Value (type 'String') for property 'Delay' does not mat
ch. Current state is '00:00:00' and desired state is '00:00:30'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] MATCH: Value (type 'String') for property 'ScheduleType' does mat
ch. Current state is 'AtLogon' and desired state is 'AtLogOn'.
VERBOSE: [REDACTED]: [[ScheduledTask]DirectResourceAccess] Test-DscParameter result is 'False'.
VERBOSE: [REDACTED]: LCM: [ End Test ] [[ScheduledTask]DirectResourceAccess] False in 0.8600 seconds.
VERBOSE: [REDACTED]: LCM: [ End Set ] in 0.9060 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 0.989 seconds
Suggested solution to the issue
Move the below line in the ScheduledTask resource in the Set-TargetResource cmdlet outside of the ScheduleType switch statement: $trigger.Delay = [System.Xml.XmlConvert]::ToString([timespan]$Delay)
The DSC configuration that is used to reproduce the issue (as detailed as possible)
No configuration to provide
The operating system the target node is running
OsName : Microsoft Windows Server 2016 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
WindowsBuildLabEx : 14393.3053.amd64fre.rs1_release_inmarket.190612-1836
OsLanguage : en-US
OsMuiLanguages : {en-US}
Version and build of PowerShell the target node is running
Just moving the set of Delay out of OnEvent is a bit to simple unfortunately. This is because not all triggers support the delay property.
Supporting Delay:
AtLogon
AtStartUp
OnEvent
Not Supporting Delay:
Daily
Weekly
Once
Also, the delay property is only supported on W2016+ / W10+, mainly because the object returned by the tooling (New-ScheduledTaskTrigger) is different on W2012 / W8 (oh MS we love your consistency).
Details of the scenario you tried and the problem that is occurring
When using the delay property for any schedule type other than OnEvent, the property is never set in the scheduled task. This causes the test to always fail and the set to always run.
Verbose logs showing the problem
Suggested solution to the issue
Move the below line in the ScheduledTask resource in the Set-TargetResource cmdlet outside of the ScheduleType switch statement:
$trigger.Delay = [System.Xml.XmlConvert]::ToString([timespan]$Delay)
The DSC configuration that is used to reproduce the issue (as detailed as possible)
No configuration to provide
The operating system the target node is running
Version and build of PowerShell the target node is running
Version of the DSC module that was used ('dev' if using current dev branch)
6.4.0.0
The text was updated successfully, but these errors were encountered: