Closed DelectableMechanisations closed 4 years ago
Adding some additional information to this as I think #328 is a duplicate (will close #328):
The ScheduledTask integration tests are failing when using a Service Account as the credential on Windows Server 2016.
The tests fail because on Windows Server 2016 the BuiltInAccount does not match:
2020-05-03T02:00:45.4481278Z VERBOSE: [fv-az172]: [[ScheduledTask]ScheduledTaskServiceAccountAdd] NOTMATCH: Value (type
2020-05-03T02:00:45.4481906Z 'System.String') for property 'BuiltInAccount' does not match. Current state is 'LOCAL SERVICE' and desired state is
2020-05-03T02:00:45.4482371Z 'NT AUTHORITY\LOCAL SERVICE'.
On Windows Server 2019 the logs show:
2020-04-27T04:31:32.2808264Z VERBOSE: [fv-az674]: [[ScheduledTask]ScheduledTaskServiceAccountAdd] MATCH: Value (type
2020-04-27T04:31:32.2809050Z 'System.String') for property 'BuiltInAccount' does match. Current state is 'NT AUTHORITY\LOCAL SERVICE' and desired
2020-04-27T04:31:32.2809421Z state is 'NT AUTHORITY\LOCAL SERVICE'.
The tests fail because on Windows Server 2016 the BuiltInAccount does not match:
2020-05-03T02:00:47.3387033Z VERBOSE: [fv-az172]: [[ScheduledTask]ScheduledTaskServiceAccountMod] NOTMATCH: Value (type
2020-05-03T02:00:47.3387834Z 'System.String') for property 'BuiltInAccount' does not match. Current state is 'NETWORK SERVICE' and desired state is
2020-05-03T02:00:47.3388450Z 'NT AUTHORITY\NETWORK SERVICE'.
On Windows Server 2019 the logs show:
2020-04-27T04:31:34.3290037Z VERBOSE: [fv-az674]: [[ScheduledTask]ScheduledTaskServiceAccountMod] MATCH: Value (type
2020-04-27T04:31:34.3290645Z 'System.String') for property 'BuiltInAccount' does match. Current state is 'NT AUTHORITY\NETWORK SERVICE' and desired
2020-04-27T04:31:34.3291030Z state is 'NT AUTHORITY\NETWORK SERVICE'.
The tests fail because on Windows Server 2016 the ExecuteAsCredential does not match:
2020-05-03T02:01:00.7419639Z VERBOSE: [fv-az172]: [[ScheduledTask]ScheduledTaskExecuteAsAdd] NOTMATCH: Value (type
2020-05-03T02:01:00.7420261Z 'System.String') for property 'ExecuteAsCredential' does not match. Current state is 'Users' and desired state is
2020-05-03T02:01:00.7424061Z 'BUILTIN\Users'.
On Windows Server 2019 the logs show:
2020-04-27T04:31:49.5811142Z VERBOSE: [fv-az674]: [[ScheduledTask]ScheduledTaskExecuteAsAdd] MATCH: Value (type
2020-04-27T04:31:49.5811856Z 'System.String') for property 'ExecuteAsCredential' does match. Current state is 'BUILTIN\Users' and desired state is
2020-04-27T04:31:49.5812199Z 'BUILTIN\Users'.
Thanks for raising @DelectableMechanisations BTW! I've got to fix this as part of PR #326 because the CI pipeline is currently in a failed state. So I'll test out your change in that PR and see if it works.
I've managed to fix one of the problems: BuiltInAccount, but still working on the ExecuteAsCredential problem.
Details of the scenario you tried and the problem that is occurring
I am trying to apply a configuration using the ScheduledTask resource and the BuiltInAccount property. Whilst the configuration applies successfully, running Test-DscConfiguration always returns false. This ultimately seems to boil down to the SYSTEM principal account name sometimes displaying as 'SYSTEM' and other times as 'NT AUTHORITY\SYSTEM'.
Verbose logs showing the problem
Suggested solution to the issue
My guess is that when commit 1ae52d58a809b5604101dc1bf443e478ac34b88c was implemented it didn't go far enough to resolve the underlying issue OR a recent Windows Update has changed the operation of the Get-ScheduledTask cmdlet and the values it returned.
I believe a change needs to be made to source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1, most likely in the section of code below:
Current:
Proposed:
The DSC configuration that is used to reproduce the issue (as detailed as possible)
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)
master (version 8.1.0 downloaded from PowerShell Gallery)