|
1 | | -configuration Sample_xScheduledTask |
| 1 | +Configuration Sample_xScheduledTask |
2 | 2 | { |
3 | | - param |
4 | | - ( |
5 | | - [string[]]$NodeName = 'localhost' |
6 | | - ) |
7 | | - |
8 | | - Import-DSCResource -ModuleName xComputerManagement |
9 | | - |
10 | | - Node $NodeName |
| 3 | + Import-DscResource -ModuleName xComputerManagement |
| 4 | + node "localhost" |
11 | 5 | { |
12 | | - xScheduledTask MaintenanceScriptExample |
| 6 | + xScheduledTask xScheduledTaskOnceAdd |
| 7 | + { |
| 8 | + TaskName = "Test task once" |
| 9 | + TaskPath = "\MyTasks" |
| 10 | + ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
| 11 | + ScheduleType = 'Once' |
| 12 | + RepeatInterval = [datetime]::Today.AddMinutes(15) |
| 13 | + RepetitionDuration = [datetime]::Today.AddHours(8) |
| 14 | + ActionWorkingPath = (Get-Location).Path |
| 15 | + Enable = $true |
| 16 | + RandomDelay = [datetime]::Today.AddMinutes(60) |
| 17 | + DisallowHardTerminate = $true |
| 18 | + RunOnlyIfIdle = $false |
| 19 | + Priority = 9 |
| 20 | + } |
| 21 | + |
| 22 | + xScheduledTask xScheduledTaskDailyAdd |
| 23 | + { |
| 24 | + TaskName = "Test task Daily" |
| 25 | + TaskPath = "\MyTasks" |
| 26 | + ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
| 27 | + ScheduleType = 'Daily' |
| 28 | + DaysInterval = 1 |
| 29 | + RepeatInterval = [datetime]::Today.AddMinutes(15) |
| 30 | + RepetitionDuration = [datetime]::Today.AddHours(8) |
| 31 | + RestartCount = 2 |
| 32 | + RestartInterval = [datetime]::Today.AddMinutes(5) |
| 33 | + RunOnlyIfNetworkAvailable = $true |
| 34 | + WakeToRun = $true |
| 35 | + } |
| 36 | + |
| 37 | + xScheduledTask xScheduledTaskWeeklyAdd |
| 38 | + { |
| 39 | + TaskName = "Test task Weekly" |
| 40 | + TaskPath = "\MyTasks" |
| 41 | + ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
| 42 | + ScheduleType = 'Weekly' |
| 43 | + WeeksInterval = 1 |
| 44 | + DaysOfWeek = 'Monday','Wednesday','Saturday' |
| 45 | + RepeatInterval = [datetime]::Today.AddMinutes(15) |
| 46 | + RepetitionDuration = [datetime]::Today.AddHours(8) |
| 47 | + AllowStartIfOnBatteries = $true |
| 48 | + Compatibility = 'Win8' |
| 49 | + Hidden = $true |
| 50 | + } |
| 51 | + |
| 52 | + xScheduledTask xScheduledTaskOnceAdd |
| 53 | + { |
| 54 | + TaskName = "Test task Logon" |
| 55 | + TaskPath = "\MyTasks" |
| 56 | + ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
| 57 | + ScheduleType = 'AtLogOn' |
| 58 | + RepeatInterval = [datetime]::Today.AddMinutes(15) |
| 59 | + RepetitionDuration = [datetime]::Today.AddHours(8) |
| 60 | + } |
| 61 | + |
| 62 | + xScheduledTask xScheduledTaskOnceAdd |
13 | 63 | { |
14 | | - TaskName = "Custom maintenance tasks" |
15 | | - ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
16 | | - ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" |
17 | | - ScheduleType = "Minutes" |
18 | | - RepeatInterval = 15 |
| 64 | + TaskName = "Test task Startup" |
| 65 | + TaskPath = "\MyTasks" |
| 66 | + ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
| 67 | + ScheduleType = 'AtStartup' |
| 68 | + RepeatInterval = [datetime]::Today.AddMinutes(15) |
| 69 | + RepetitionDuration = [datetime]::Today.AddHours(8) |
19 | 70 | } |
20 | 71 | } |
21 | 72 | } |
|
0 commit comments