Skip to content

Commit e5d4d77

Browse files
authored
Refactor PowerShell job trigger examples
1 parent b85f0e9 commit e5d4d77

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

reference/5.1/PSScheduledJob/New-JobTrigger.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ by the job trigger.
188188
This example creates a repeating job trigger to only run for a specific amount of time.
189189

190190
```powershell
191-
New-JobTrigger -Once -At "09/12/2013 1:00:00" -RepetitionInterval (New-TimeSpan -Hours 1) -RepetitionDuration (New-TimeSpan -Hours 48)
191+
$newJobTriggerSplat = @{
192+
Once = -Once
193+
At = "09/12/2013 1:00:00"
194+
RepetitionInterval = (New-TimeSpan -Hours 1)
195+
RepetitionDuration = (New-TimeSpan -Hours 48)
196+
}
197+
New-JobTrigger @newJobTriggerSplat
192198
```
193199

194200
This command creates a job trigger that runs a job every 60 minutes for 48 hours beginning on
@@ -199,7 +205,8 @@ September 12, 2013 at 1:00 AM.
199205
This example stops a repeating job trigger.
200206

201207
```powershell
202-
Get-JobTrigger -Name SecurityCheck | Set-JobTrigger -RepetitionInterval 0:00 -RepetitionDuration 0:00
208+
Get-JobTrigger -Name SecurityCheck |
209+
Set-JobTrigger -RepetitionInterval 0:00 -RepetitionDuration 0:00
203210
```
204211

205212
This command forcibly stops the **SecurityCheck** job, which is triggered to run every 60 minutes
@@ -214,7 +221,13 @@ repetition duration of the job trigger to zero (`0`).
214221
This example creates a repeating job trigger that runs indefinitely.
215222

216223
```powershell
217-
New-JobTrigger -Once -At "9/21/2012 0am" -RepetitionInterval (New-TimeSpan -Hour 12) -RepetitionDuration ([timespan]::MaxValue)
224+
$newJobTriggerSplat = @{
225+
Once = -Once
226+
At = "9/21/2012 0am"
227+
RepetitionInterval = (New-TimeSpan -Hour 12)
228+
RepetitionDuration = ([timespan]::MaxValue)
229+
}
230+
New-JobTrigger @newJobTriggerSplat
218231
```
219232

220233
The following command creates a job trigger that runs a scheduled job once every 12 hours for an

0 commit comments

Comments
 (0)