Skip to content

Commit 5f98cfe

Browse files
authored
Merge branch 'master' into fix/2017-add-example
2 parents 9bef546 + 386a3d1 commit 5f98cfe

File tree

5 files changed

+136
-61
lines changed

5 files changed

+136
-61
lines changed

docset/winserver2012-ps/scheduledtasks/New-ScheduledTask.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ You can register a task to run any of the following application or file types: W
2727
## EXAMPLES
2828

2929
### Example 1: Define a scheduled task and register it at a later time
30-
```
31-
PS C:\> $A = New-ScheduledTaskAction -Execute "Taskmgr.exe" PS C:\>$T = New-ScheduledTaskTrigger -AtLogon PS C:\>$P = "Contoso\Administrator" PS C:\>$S = New-ScheduledTaskSettingsSet PS C:\>$D = New-ScheduledTask -Action $A -Principal $P -Trigger $T -Settings $S PS C:\>Register-ScheduledTask T1 -InputObject $D
30+
```powershell
31+
PS C:\> $action = New-ScheduledTaskAction -Execute "Taskmgr.exe"
32+
PS C:\> $trigger = New-ScheduledTaskTrigger -AtLogon
33+
PS C:\> $principal = "Contoso\Administrator"
34+
PS C:\> $settings = New-ScheduledTaskSettingsSet
35+
PS C:\> $task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings
36+
PS C:\> Register-ScheduledTask T1 -InputObject $task
3237
```
3338

3439
In this example, the set of commands uses several cmdlets and variables to define and then register a scheduled task.
@@ -46,6 +51,20 @@ The fifth command creates a new task and assigns the task definition to the vari
4651
The sixth command (hypothetically) runs at a later time.
4752
It registers the new scheduled task and defines it by using the $D variable.
4853

54+
### Example 2: Define a scheduled task with multiple actions
55+
```powershell
56+
PS C:\> $actions = (New-ScheduledTaskAction –Execute 'foo.ps1'), (New-ScheduledTaskAction –Execute 'bar.ps1')
57+
PS C:\> $trigger = New-ScheduledTaskTrigger -Daily -At '9:15 AM'
58+
PS C:\> $principal = New-ScheduledTaskPrincipal -UserId 'DOMAIN\user' -RunLevel Highest
59+
PS C:\> $settings = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable -WakeToRun
60+
PS C:\> $task = New-ScheduledTask -Action $actions -Principal $principal -Trigger $trigger -Settings $settings
61+
62+
PS C:\> Register-ScheduledTask 'baz' -InputObject $task
63+
64+
```
65+
66+
This example creates and registers a scheduled task that runs two PowerShell scripts daily at 09:15 AM.
67+
4968
## PARAMETERS
5069

5170
### -Action
@@ -56,7 +75,7 @@ A task can have up to 32 actions.
5675
```yaml
5776
Type: CimInstance[]
5877
Parameter Sets: (All)
59-
Aliases:
78+
Aliases:
6079

6180
Required: False
6281
Position: 1
@@ -71,7 +90,7 @@ Runs the cmdlet as a background job. Use this parameter to run commands that tak
7190
```yaml
7291
Type: SwitchParameter
7392
Parameter Sets: (All)
74-
Aliases:
93+
Aliases:
7594

7695
Required: False
7796
Position: Named
@@ -103,7 +122,7 @@ Briefly describes the task.
103122
```yaml
104123
Type: String
105124
Parameter Sets: (All)
106-
Aliases:
125+
Aliases:
107126

108127
Required: False
109128
Position: 5
@@ -118,7 +137,7 @@ Specifies the security context in which a task runs.
118137
```yaml
119138
Type: CimInstance
120139
Parameter Sets: (All)
121-
Aliases:
140+
Aliases:
122141

123142
Required: False
124143
Position: 4
@@ -133,7 +152,7 @@ Specifies a configuration object that the Task Scheduler service uses to determi
133152
```yaml
134153
Type: CimInstance
135154
Parameter Sets: (All)
136-
Aliases:
155+
Aliases:
137156

138157
Required: False
139158
Position: 3
@@ -150,7 +169,7 @@ The throttle limit applies only to the current cmdlet, not to the session or to
150169
```yaml
151170
Type: Int32
152171
Parameter Sets: (All)
153-
Aliases:
172+
Aliases:
154173
155174
Required: False
156175
Position: Named
@@ -171,7 +190,7 @@ For more information about triggers, see [Triggers](https://technet.microsoft.co
171190
```yaml
172191
Type: CimInstance[]
173192
Parameter Sets: (All)
174-
Aliases:
193+
Aliases:
175194
176195
Required: False
177196
Position: 2

docset/winserver2012r2-ps/scheduledtasks/New-ScheduledTask.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ You can register a task to run any of the following application or file types: W
3030

3131
### Example 1: Define a scheduled task and register it at a later time
3232
```powershell
33-
PS C:\> $A = New-ScheduledTaskAction -Execute "Taskmgr.exe"
34-
PS C:\> $T = New-ScheduledTaskTrigger -AtLogon
35-
PS C:\> $P = "Contoso\Administrator"
36-
PS C:\> $S = New-ScheduledTaskSettingsSet
37-
PS C:\> $D = New-ScheduledTask -Action $A -Principal $P -Trigger $T -Settings $S
38-
PS C:\> Register-ScheduledTask T1 -InputObject $D
33+
PS C:\> $action = New-ScheduledTaskAction -Execute "Taskmgr.exe"
34+
PS C:\> $trigger = New-ScheduledTaskTrigger -AtLogon
35+
PS C:\> $principal = "Contoso\Administrator"
36+
PS C:\> $settings = New-ScheduledTaskSettingsSet
37+
PS C:\> $task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings
38+
PS C:\> Register-ScheduledTask T1 -InputObject $task
3939
```
4040

4141
In this example, the set of commands uses several cmdlets and variables to define and then register a scheduled task.
@@ -53,6 +53,20 @@ The fifth command creates a new task and assigns the task definition to the vari
5353
The sixth command (hypothetically) runs at a later time.
5454
It registers the new scheduled task and defines it by using the $D variable.
5555

56+
### Example 2: Define a scheduled task with multiple actions
57+
```powershell
58+
PS C:\> $actions = (New-ScheduledTaskAction –Execute 'foo.ps1'), (New-ScheduledTaskAction –Execute 'bar.ps1')
59+
PS C:\> $trigger = New-ScheduledTaskTrigger -Daily -At '9:15 AM'
60+
PS C:\> $principal = New-ScheduledTaskPrincipal -UserId 'DOMAIN\user' -RunLevel Highest
61+
PS C:\> $settings = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable -WakeToRun
62+
PS C:\> $task = New-ScheduledTask -Action $actions -Principal $principal -Trigger $trigger -Settings $settings
63+
64+
PS C:\> Register-ScheduledTask 'baz' -InputObject $task
65+
66+
```
67+
68+
This example creates and registers a scheduled task that runs two PowerShell scripts daily at 09:15 AM.
69+
5670
## PARAMETERS
5771

5872
### -Action
@@ -63,7 +77,7 @@ A task can have up to 32 actions.
6377
```yaml
6478
Type: CimInstance[]
6579
Parameter Sets: (All)
66-
Aliases:
80+
Aliases:
6781

6882
Required: False
6983
Position: 0
@@ -78,7 +92,7 @@ Runs the cmdlet as a background job. Use this parameter to run commands that tak
7892
```yaml
7993
Type: SwitchParameter
8094
Parameter Sets: (All)
81-
Aliases:
95+
Aliases:
8296

8397
Required: False
8498
Position: Named
@@ -110,7 +124,7 @@ Briefly describes the task.
110124
```yaml
111125
Type: String
112126
Parameter Sets: (All)
113-
Aliases:
127+
Aliases:
114128

115129
Required: False
116130
Position: 4
@@ -125,7 +139,7 @@ Specifies the security context in which a task runs.
125139
```yaml
126140
Type: CimInstance
127141
Parameter Sets: (All)
128-
Aliases:
142+
Aliases:
129143

130144
Required: False
131145
Position: 3
@@ -140,7 +154,7 @@ Specifies a configuration object that the Task Scheduler service uses to determi
140154
```yaml
141155
Type: CimInstance
142156
Parameter Sets: (All)
143-
Aliases:
157+
Aliases:
144158

145159
Required: False
146160
Position: 2
@@ -157,7 +171,7 @@ The throttle limit applies only to the current cmdlet, not to the session or to
157171
```yaml
158172
Type: Int32
159173
Parameter Sets: (All)
160-
Aliases:
174+
Aliases:
161175
162176
Required: False
163177
Position: Named
@@ -177,7 +191,7 @@ For more information about triggers, see [Triggers](https://technet.microsoft.co
177191
```yaml
178192
Type: CimInstance[]
179193
Parameter Sets: (All)
180-
Aliases:
194+
Aliases:
181195
182196
Required: False
183197
Position: 1

docset/winserver2016-ps/scheduledtasks/New-ScheduledTask.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ You can register a task to run any of the following application or file types: W
3131

3232
### Example 1: Define a scheduled task and register it at a later time
3333
```powershell
34-
PS C:\> $A = New-ScheduledTaskAction -Execute "Taskmgr.exe"
35-
PS C:\> $T = New-ScheduledTaskTrigger -AtLogon
36-
PS C:\> $P = New-ScheduledTaskPrincipal "Contoso\Administrator"
37-
PS C:\> $S = New-ScheduledTaskSettingsSet
38-
PS C:\> $D = New-ScheduledTask -Action $A -Principal $P -Trigger $T -Settings $S
39-
PS C:\> Register-ScheduledTask T1 -InputObject $D
34+
PS C:\> $action = New-ScheduledTaskAction -Execute "Taskmgr.exe"
35+
PS C:\> $trigger = New-ScheduledTaskTrigger -AtLogon
36+
PS C:\> $principal = "Contoso\Administrator"
37+
PS C:\> $settings = New-ScheduledTaskSettingsSet
38+
PS C:\> $task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings
39+
PS C:\> Register-ScheduledTask T1 -InputObject $task
4040
```
4141

4242
In this example, the set of commands uses several cmdlets and variables to define and then register a scheduled task.
@@ -54,6 +54,20 @@ The fifth command creates a new task and assigns the task definition to the vari
5454
The sixth command (hypothetically) runs at a later time.
5555
It registers the new scheduled task and defines it by using the $D variable.
5656

57+
### Example 2: Define a scheduled task with multiple actions
58+
```powershell
59+
PS C:\> $actions = (New-ScheduledTaskAction –Execute 'foo.ps1'), (New-ScheduledTaskAction –Execute 'bar.ps1')
60+
PS C:\> $trigger = New-ScheduledTaskTrigger -Daily -At '9:15 AM'
61+
PS C:\> $principal = New-ScheduledTaskPrincipal -UserId 'DOMAIN\user' -RunLevel Highest
62+
PS C:\> $settings = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable -WakeToRun
63+
PS C:\> $task = New-ScheduledTask -Action $actions -Principal $principal -Trigger $trigger -Settings $settings
64+
65+
PS C:\> Register-ScheduledTask 'baz' -InputObject $task
66+
67+
```
68+
69+
This example creates and registers a scheduled task that runs two PowerShell scripts daily at 09:15 AM.
70+
5771
## PARAMETERS
5872

5973
### -Action
@@ -64,7 +78,7 @@ A task can have up to 32 actions.
6478
```yaml
6579
Type: CimInstance[]
6680
Parameter Sets: (All)
67-
Aliases:
81+
Aliases:
6882

6983
Required: False
7084
Position: 0
@@ -79,7 +93,7 @@ Runs the cmdlet as a background job. Use this parameter to run commands that tak
7993
```yaml
8094
Type: SwitchParameter
8195
Parameter Sets: (All)
82-
Aliases:
96+
Aliases:
8397

8498
Required: False
8599
Position: Named
@@ -111,7 +125,7 @@ Briefly describes the task.
111125
```yaml
112126
Type: String
113127
Parameter Sets: (All)
114-
Aliases:
128+
Aliases:
115129

116130
Required: False
117131
Position: 4
@@ -126,7 +140,7 @@ Specifies the security context in which a task runs.
126140
```yaml
127141
Type: CimInstance
128142
Parameter Sets: (All)
129-
Aliases:
143+
Aliases:
130144

131145
Required: False
132146
Position: 3
@@ -141,7 +155,7 @@ Specifies a configuration object that the Task Scheduler service uses to determi
141155
```yaml
142156
Type: CimInstance
143157
Parameter Sets: (All)
144-
Aliases:
158+
Aliases:
145159

146160
Required: False
147161
Position: 2
@@ -158,7 +172,7 @@ The throttle limit applies only to the current cmdlet, not to the session or to
158172
```yaml
159173
Type: Int32
160174
Parameter Sets: (All)
161-
Aliases:
175+
Aliases:
162176
163177
Required: False
164178
Position: Named
@@ -178,7 +192,7 @@ For more information about triggers, see [Triggers](https://technet.microsoft.co
178192
```yaml
179193
Type: CimInstance[]
180194
Parameter Sets: (All)
181-
Aliases:
195+
Aliases:
182196
183197
Required: False
184198
Position: 1

0 commit comments

Comments
 (0)