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
309 stars 82 forks source link

ScheduledTask: ScheduleType Parameter mismatch for `AtLogOn` #420

Closed jordanbreen28 closed 11 months ago

jordanbreen28 commented 12 months ago

Problem description

Accepted values for the ScheduleType parameter are Once, Daily, Weekly, AtStartup, AtLogOn and OnEvent. However, when applying the below configuration, and supplying any variation of AtLogOn, AtLogon, Atlogon or atlogon, the value is always set and returned as AtLogon. I would argue this is a bug, as the value saved should match one of the "acceptable" values defined in the schema. So the value saved against the resource should be AtLogon and the accepted value here https://github.com/dsccommunity/ComputerManagementDsc/blob/d05adb09e753e0deebd7687b83dbba6584dfc6c7/source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.schema.mof#L10, updated to AtLogon.

Verbose logs

VERBOSE: [WIN-U00GQQ2VB88]:                            [[ScheduledTask]ScheduledTaskLogonAdd] MATCH: Value (type 'System.String') for property 'ScheduleType' does match. Current 
state is 'AtLogon' and desired state is 'AtLogOn'. (DRC0020)

DSC configuration

Configuration ScheduledTask_CreateScheduledTasksAtLogon_Config
{
    Import-DscResource -ModuleName ComputerManagementDsc

     Node 'localhost'
    {
        ScheduledTask ScheduledTaskLogonAdd
        {
            TaskName           = 'SessionPopup'
            actionexecutable   = 'powershell'
            actionarguments    = '-File "C:\Program Files\windowspowershell\scripts\Epic.Wss.sessionpopup\Epic.Wss.SessionPopup.ps1"'
            ScheduleType       = 'AtLogOn'
        }
    }
}

ScheduledTask_CreateScheduledTasksAtLogon_Config

Suggested solution

Update the allowed values at https://github.com/dsccommunity/ComputerManagementDsc/blob/d05adb09e753e0deebd7687b83dbba6584dfc6c7/source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.schema.mof#L10 to accept AtLogon over AtLogOn.

Operating system the target node is running

Windows server 2019

PowerShell version and build the target node is running

5.1.17763.3770

ComputerManagementDsc version

9.0.0