-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from PlagueHO/dev
BREAKING CHANGE: xScheduledTask Duration/Interval Fields Changed to Strings - Fixes #85
- Loading branch information
Showing
16 changed files
with
1,935 additions
and
993 deletions.
There are no files selected for viewing
1,384 changes: 791 additions & 593 deletions
1,384
DSCResources/MSFT_xScheduledTask/MSFT_xScheduledTask.psm1
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<# | ||
.EXAMPLE | ||
This example creates a scheduled task called 'Test task Once' in the folder | ||
task folder 'MyTasks' that starts a new powershell process once at 00:00 repeating | ||
every 15 minutes for 8 hours. The task is delayed by a random amount up to 1 hour | ||
each time. The task will run even if the previous task is still running and it | ||
will prevent hard termintaing of the previously running task instance. | ||
#> | ||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter()] | ||
[System.String[]] | ||
$NodeName = 'localhost' | ||
) | ||
|
||
Import-DscResource -ModuleName xComputerManagement | ||
|
||
Node $NodeName | ||
{ | ||
xScheduledTask xScheduledTaskOnceAdd | ||
{ | ||
TaskName = 'Test task Once' | ||
TaskPath = '\MyTasks' | ||
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' | ||
ScheduleType = 'Once' | ||
RepeatInterval = '00:15:00' | ||
RepetitionDuration = '08:00:00' | ||
ActionWorkingPath = (Get-Location).Path | ||
Enable = $true | ||
RandomDelay = '01:00:00' | ||
DisallowHardTerminate = $true | ||
RunOnlyIfIdle = $false | ||
Priority = 9 | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<# | ||
.EXAMPLE | ||
This example creates a scheduled task called 'Test task Daily' in the folder | ||
task folder 'MyTasks' that starts a new powershell process every day at 00:00 repeating | ||
every 15 minutes for 8 hours. If the task fails it will be restarted after 5 minutes | ||
and it will be restarted a maximum of two times. It will only run if the network | ||
is connected and will wake the machine up to execute the task. | ||
#> | ||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter()] | ||
[System.String[]] | ||
$NodeName = 'localhost' | ||
) | ||
|
||
Import-DscResource -ModuleName xComputerManagement | ||
|
||
Node $NodeName | ||
{ | ||
xScheduledTask xScheduledTaskDailyAdd | ||
{ | ||
TaskName = 'Test task Daily' | ||
TaskPath = '\MyTasks' | ||
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' | ||
ScheduleType = 'Daily' | ||
DaysInterval = 1 | ||
RepeatInterval = '00:15:00' | ||
RepetitionDuration = '08:00:00' | ||
RestartCount = 2 | ||
RestartInterval = '00:05:00' | ||
RunOnlyIfNetworkAvailable = $true | ||
WakeToRun = $true | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Examples/xScheduledTask/3-CreateScheduledTasksDailyIndefinitely.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<# | ||
.EXAMPLE | ||
This example creates a scheduled task called 'Test task Daily Indefinitely' in the folder | ||
task folder 'MyTasks' that starts a new powershell process every day at 00:00 repeating | ||
every 15 minutes indefinitely. | ||
#> | ||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter()] | ||
[System.String[]] | ||
$NodeName = 'localhost' | ||
) | ||
|
||
Import-DscResource -ModuleName xComputerManagement | ||
|
||
Node $NodeName | ||
{ | ||
xScheduledTask xScheduledTaskDailyIndefinitelyAdd | ||
{ | ||
TaskName = 'Test task Daily Indefinitely' | ||
TaskPath = '\MyTasks' | ||
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' | ||
ScheduleType = 'Daily' | ||
DaysInterval = 1 | ||
RepeatInterval = '00:15:00' | ||
RepetitionDuration = 'Indefinitely' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<# | ||
.EXAMPLE | ||
This example creates a scheduled task called 'Test task Weekly' in the folder | ||
task folder 'MyTasks' that starts a new powershell process every week on | ||
Monday, Wednesday and Saturday at 00:00 repeating every 15 minutes for 8 hours. | ||
The task will be hidden and will be allowed to start if the machine is running | ||
on batteries. The task will be compatible with Windows 8. | ||
#> | ||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter()] | ||
[System.String[]] | ||
$NodeName = 'localhost' | ||
) | ||
|
||
Import-DscResource -ModuleName xComputerManagement | ||
|
||
Node $NodeName | ||
{ | ||
xScheduledTask xScheduledTaskWeeklyAdd | ||
{ | ||
TaskName = 'Test task Weekly' | ||
TaskPath = '\MyTasks' | ||
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' | ||
ScheduleType = 'Weekly' | ||
WeeksInterval = 1 | ||
DaysOfWeek = 'Monday','Wednesday','Saturday' | ||
RepeatInterval = '00:15:00' | ||
RepetitionDuration = '08:00:00' | ||
AllowStartIfOnBatteries = $true | ||
Compatibility = 'Win8' | ||
Hidden = $true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<# | ||
.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 xComputerManagement | ||
|
||
Node $NodeName | ||
{ | ||
xScheduledTask xScheduledTaskLogonAdd | ||
{ | ||
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' | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Examples/xScheduledTask/6-CreateScheduledTasksAtStartup.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<# | ||
.EXAMPLE | ||
This example creates a scheduled task called 'Test task Startup' in the folder | ||
task folder 'MyTasks' that starts a new powershell process when the machine | ||
is started up repeating every 15 minutes for 8 hours. | ||
#> | ||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter()] | ||
[System.String[]] | ||
$NodeName = 'localhost' | ||
) | ||
|
||
Import-DscResource -ModuleName xComputerManagement | ||
|
||
Node $NodeName | ||
{ | ||
xScheduledTask xScheduledTaskStartupAdd | ||
{ | ||
TaskName = 'Test task Startup' | ||
TaskPath = '\MyTasks' | ||
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' | ||
ScheduleType = 'AtStartup' | ||
RepeatInterval = '00:15:00' | ||
RepetitionDuration = '08:00:00' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Examples/xScheduledTask/8-RunPowerShellTaskEvery15MinutesIndefinitely.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<# | ||
.EXAMPLE | ||
This example will create a scheduled task that will call PowerShell.exe every 15 | ||
minutes indefinitely to run a script saved locally. The task will start immediately. | ||
The script will be called as the local system account. | ||
#> | ||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter()] | ||
[System.String[]] | ||
$NodeName = 'localhost' | ||
) | ||
|
||
Import-DscResource -ModuleName xComputerManagement | ||
|
||
Node $NodeName | ||
{ | ||
xScheduledTask MaintenanceScriptExample | ||
{ | ||
TaskName = "Custom maintenance tasks" | ||
ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" | ||
ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" | ||
ScheduleType = 'Once' | ||
RepeatInterval = '00:15:00' | ||
RepetitionDuration = 'Indefinitely' | ||
} | ||
} | ||
} |
Oops, something went wrong.