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
306 stars 83 forks source link

issue with scheduledtask starttype #293

Closed ewhitesides closed 4 years ago

ewhitesides commented 4 years ago

My DSC configuration for scheduledtask resources reports as not in desired state, and my suspicion is that it has to do with the ScheduleType parameter.

Here is an example of working scheduledtask resource:

ScheduledTask workingtask { TaskName = 'workingtask' TaskPath = '\' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ActionArguments = "my command here" ScheduleType = 'Daily' StartTime = (Get-Date '11:30pm') | Get-Date -Format s DaysInterval = 1 ExecutionTimeLimit = '01:00:00' SynchronizeAcrossTimeZone = $false RunOnlyIfNetworkAvailable = $true ExecuteAsCredential = $DomainAdminCred RunLevel = 'Highest' DependsOn = '[cPowerShellModuleManagement]EventLogTools','[xEventLog]CustomLog','[cPowerShellModuleManagement]CopyTools' }

this is an example of a task that reports as incorrect:

ScheduledTask task2 { TaskName = 'task2' TaskPath = '\' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ActionArguments = "my command here" ScheduleType = 'Once' StartTime = Get-Date '12:15pm' | Get-Date -Format s RepeatInterval = '12:00:00' RepetitionDuration = 'Indefinitely' ExecutionTimeLimit = '01:00:00' SynchronizeAcrossTimeZone = $true RunOnlyIfNetworkAvailable = $true ExecuteAsCredential = $DomainAdminCred RunLevel = 'Highest' DependsOn = '[cPowerShellModuleManagement]EventLogTools','[xEventLog]CustomLog','[cPowerShellModuleManagement]DownloadTools' }

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

Verbose logs showing the problem

Suggested solution to the issue

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

# insert configuration here

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)