Examples/Resources/ScheduledTask/5-CreateScheduledTasksAtLogon.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#
    .EXAMPLE
    This example creates a scheduled task called 'Test task Logon' in the folder
    task folder 'MyTasks' that starts a new powershell process when the machine
    is logged on repeating every 15 minutes for 8 hours.
#>

Configuration Example
{
    param
    (
        [Parameter()]
        [System.String[]]
        $NodeName = 'localhost'
    )

    Import-DscResource -ModuleName ComputerManagementDsc

    Node $NodeName
    {
        ScheduledTask ScheduledTaskLogonAdd
        {
            TaskName           = 'Test task Logon'
            TaskPath           = '\MyTasks'
            ActionExecutable   = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
            ScheduleType       = 'AtLogOn'
            RepeatInterval     = '00:15:00'
            RepetitionDuration = '08:00:00'
        }
    }
}