Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScheduledTask: Test-DscConfiguration always in not desired state #411

Open
luigilink opened this issue Apr 17, 2023 · 1 comment
Open

ScheduledTask: Test-DscConfiguration always in not desired state #411

luigilink opened this issue Apr 17, 2023 · 1 comment

Comments

@luigilink
Copy link

luigilink commented Apr 17, 2023

Problem description

Test-DscConfiguration returns false even if each parameter is in the desired state.
The parameter StartTime is initialized every day so it can't be in the desired state.
This task was created the april 7th.

Get-TargetResource -TaskName 'CleanLogFolders' -TaskPath 'SharePoint'
Name Value


User CONTOSO\SPFarmAdm
ExecutionTimeLimit 3.00:00:00
Enable True
EventSubscription
StartTime 07/04/2023 02:00:00
LogonType Password
TaskName CleanLogFolders
ExecuteAsGMSA SPFarmAdm
RestartCount 0
DontStopOnIdleEnd False
ExecuteAsCredential CONTOSO\SPFarmAdm
WeeksInterval 0
IdleDuration 01:00:00
AllowStartIfOnBatteries False
NetworkName
Ensure Present
DontStopIfGoingOnBatteries False
DaysInterval 1
DisallowDemandStart False
DisallowStartOnRemoteAppSes... False
SynchronizeAcrossTimeZone False
RandomDelay 00:00:00
Hidden False
RunOnlyIfNetworkAvailable False
DisallowHardTerminate False
RepeatInterval 00:00:00
Description CleanLogFolders Task - Start at 2:00 daily
MultipleInstances Queue
RepetitionDuration Indefinitely
ScheduleType Daily
TaskPath \SharePoint\
StartWhenAvailable False
IdleWaitTimeout 02:00:00
RunOnlyIfIdle False
Delay 00:00:00
RestartInterval 00:00:00
ActionArguments -ExecutionPolicy Bypass E:\Tools\SCRIPTS\Clea...
Compatibility Win7
ActionWorkingPath
RunLevel Highest
RestartOnIdle False
DaysOfWeek {}
Priority 7
ActionExecutable C:\Windows\System32\WindowsPowerShell\v1.0\po...
WakeToRun False

Verbose logs

[[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1627197Z 'System.String') for property 'ActionArguments' does match. Current state is 
2023-04-17T08:57:43.1627727Z '-ExecutionPolicy Bypass 
2023-04-17T08:57:43.1628003Z E:\Tools\SCRIPTS\CleanLogFolders\1.0.0\CleanLogFolders.ps1' and desired state 
2023-04-17T08:57:43.1628084Z is '-ExecutionPolicy Bypass 
2023-04-17T08:57:43.1628142Z E:\Tools\SCRIPTS\CleanLogFolders\1.0.0\CleanLogFolders.ps1'. (DRC0020)
2023-04-17T08:57:43.1650740Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1650865Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1650927Z 'System.String') for property 'Description' does match. Current state is 
2023-04-17T08:57:43.1651003Z 'CleanLogFolders Task - Start at 2:00 daily' and desired state is 
2023-04-17T08:57:43.1651088Z 'CleanLogFolders Task - Start at 2:00 daily'. (DRC0020)
2023-04-17T08:57:43.1666225Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1666457Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1666604Z 'System.String') for property 'ScheduleType' does match. Current state is 
2023-04-17T08:57:43.1666796Z 'Daily' and desired state is 'Daily'. (DRC0020)
2023-04-17T08:57:43.1682494Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1682655Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1682726Z 'System.String') for property 'TaskPath' does match. Current state is 
2023-04-17T08:57:43.1682789Z '\SharePoint\' and desired state is '\SharePoint\'. (DRC0020)
2023-04-17T08:57:43.1698866Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1699085Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1699584Z 'System.String') for property 'Ensure' does match. Current state is 'Present' 
2023-04-17T08:57:43.1699686Z and desired state is 'Present'. (DRC0020)
2023-04-17T08:57:43.1714922Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1715064Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1715140Z 'System.Boolean') for property 'Enable' does match. Current state is 'True' and
2023-04-17T08:57:43.1715203Z  desired state is 'True'. (DRC0020)
2023-04-17T08:57:43.1730826Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1731062Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1731231Z 'System.UInt32') for property 'DaysInterval' does match. Current state is '1' 
2023-04-17T08:57:43.1731811Z and desired state is '1'. (DRC0020)
2023-04-17T08:57:43.1748142Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1748330Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1748392Z 'System.String') for property 'RunLevel' does match. Current state is 'Highest'
2023-04-17T08:57:43.1748450Z  and desired state is 'Highest'. (DRC0020)
2023-04-17T08:57:43.1764069Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1764274Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1764367Z 'System.String') for property 'TaskName' does match. Current state is 
2023-04-17T08:57:43.1765196Z 'CleanLogFolders' and desired state is 'CleanLogFolders'. (DRC0020)
2023-04-17T08:57:43.1780703Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1780913Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] NOTMATCH: Value (type 
2023-04-17T08:57:43.1780989Z 'System.String') for property 'StartTime' does not match. Current state is 
2023-04-17T08:57:43.1781751Z '2023-04-07T02:00:00' and desired state is '2023-04-17T02:00:00'. (DRC0021)
2023-04-17T08:57:43.1797770Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1798238Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1798359Z 'System.String') for property 'ExecuteAsCredential' does match. Current state 
2023-04-17T08:57:43.1798434Z is 'CONTOSO\SPFarmAdm' and desired state is 'CONTOSO\SPFarmAdm'. 
2023-04-17T08:57:43.1798510Z (DRC0020)
2023-04-17T08:57:43.1814044Z VERBOSE: [**************]:                            
2023-04-17T08:57:43.1814196Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] MATCH: Value (type 
2023-04-17T08:57:43.1814258Z 'System.String') for property 'ActionExecutable' does match. Current state is 
2023-04-17T08:57:43.1814321Z 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' and desired state 
2023-04-17T08:57:43.1814570Z is 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'. (DRC0020)
2023-04-17T08:57:43.1824332Z VERBOSE: [**************]: LCM:  [ End    Test     ]  
2023-04-17T08:57:43.1825727Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript] False in 2.2350 seconds.
2023-04-17T08:57:43.1832444Z VERBOSE: [**************]: LCM:  [ End    Resource ]  
2023-04-17T08:57:43.1834624Z [[ScheduledTask]APPLICATION_CleanLogFolders_SCript]

DSC configuration

$CleanLogFoldersFullPath = "$($logsDrive)$($jsonCfg.SharePoint.Binaries.Tools.SCRIPTSDestination)\CleanLogFolders\$($jsonCfg.SharePoint.Binaries.Tools.CleanLogFoldersVersion)"
            ScheduledTask APPLICATION_CleanLogFolders_SCript {
                DependsOn            = '[File]APPLICATION_Copy_SCRIPTS_Folder'
                PsDscRunAsCredential = $ADM
                TaskName             = 'CleanLogFolders'
                TaskPath             = 'SharePoint'
                StartTime            = '02:00:00'
                ScheduleType         = 'Daily'
                DaysInterval         = 1
                Ensure               = 'Present'
                Enable               = $true
                ActionExecutable     = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
                ActionArguments      = "-ExecutionPolicy Bypass $($CleanLogFoldersFullPath)\CleanLogFolders.ps1"
                ExecuteAsCredential  = $ADM
                Description          = 'CleanLogFolders Task - Start at 2:00 daily'
                RunLevel             = 'Highest'
            }

Suggested solution

I didn't see differences between desired state and Get-TargetResource.
Do I have to fill every parameters ?

Operating system the target node is running

OsName               : Microsoft Windows Server 2016 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsBuildLabEx    : 14393.5717.amd64fre.rs1_release.230203-1742
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

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

ComputerManagementDsc version

Name                  Version Path
----                  ------- ----
ComputerManagementDsc 9.0.0   C:\Program Files\WindowsPowerShell\Modules\ComputerManagementDsc\9.0.0\ComputerManagem...
@luigilink
Copy link
Author

I changed the StartTime parameter with the value => StartTime = '2017-03-03T02:00:00' instead of StartTime = '02:00:00'
If you only choose time for this parameter, it change every day and add the current date before the time value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant