Skip to content

Commit 601df90

Browse files
committed
Samples added
1 parent 1941c0a commit 601df90

1 file changed

Lines changed: 66 additions & 15 deletions

File tree

Examples/Sample_xScheduledTask.ps1

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,72 @@
1-
configuration Sample_xScheduledTask
1+
Configuration Sample_xScheduledTask
22
{
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"
115
{
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
1363
{
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)
1970
}
2071
}
2172
}

0 commit comments

Comments
 (0)