|
39 | 39 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
40 | 40 | ScheduleType = "Once" |
41 | 41 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 42 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Minutes 150) |
42 | 43 | } |
43 | 44 |
|
44 | 45 | Mock Get-ScheduledTask { return $null } |
|
62 | 63 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
63 | 64 | ScheduleType = "Once" |
64 | 65 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 66 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Minutes 15) |
65 | 67 | Ensure = "Absent" |
66 | 68 | } |
67 | 69 |
|
|
73 | 75 | }) |
74 | 76 | Triggers = @(@{ |
75 | 77 | Repetition = @{ |
76 | | - Duration = $null |
| 78 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalMinutes)M" |
77 | 79 | Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
78 | 80 | } |
79 | 81 | CimClass = @{ |
|
124 | 126 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
125 | 127 | ScheduleType = "Once" |
126 | 128 | RepeatInterval =[datetime]::Today + (New-TimeSpan -Minutes 15) |
| 129 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Minutes 150) |
127 | 130 | } |
128 | 131 |
|
129 | 132 | Mock Get-ScheduledTask { return @{ |
|
156 | 159 |
|
157 | 160 | It "should update the scheduled task in the set method" { |
158 | 161 | Set-TargetResource @testParams |
159 | | - Assert-MockCalled Set-ScheduledTask |
| 162 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 163 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
160 | 164 | } |
161 | 165 | } |
162 | 166 |
|
|
166 | 170 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
167 | 171 | ScheduleType = "Once" |
168 | 172 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 173 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Minutes 30) |
169 | 174 | } |
170 | 175 |
|
171 | 176 | Mock Get-ScheduledTask { return @{ |
|
176 | 181 | }) |
177 | 182 | Triggers = @(@{ |
178 | 183 | Repetition = @{ |
179 | | - Duration = $null |
| 184 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalMinutes)M" |
180 | 185 | Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
181 | 186 | } |
182 | 187 | CimClass = @{ |
|
203 | 208 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
204 | 209 | ScheduleType = "Once" |
205 | 210 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Hours 4) |
| 211 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
206 | 212 | } |
207 | 213 |
|
208 | 214 | Mock Get-ScheduledTask { return @{ |
|
213 | 219 | }) |
214 | 220 | Triggers = @(@{ |
215 | 221 | Repetition = @{ |
216 | | - Duration = $null |
| 222 | + Duration = "PT$(($testParams.RepetitionDuration.TimeOfDay.TotalHours))H" |
217 | 223 | Interval = "PT$(($testParams.RepeatInterval.TimeOfDay.TotalHours) + 1)H" |
218 | 224 | } |
219 | 225 | CimClass = @{ |
|
235 | 241 |
|
236 | 242 | It "should update the scheduled task in the set method" { |
237 | 243 | Set-TargetResource @testParams |
238 | | - Assert-MockCalled Set-ScheduledTask |
| 244 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 245 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
239 | 246 | } |
240 | 247 | } |
241 | 248 |
|
|
245 | 252 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
246 | 253 | ScheduleType = "Once" |
247 | 254 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Hours 4) |
| 255 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
248 | 256 | } |
249 | 257 |
|
250 | 258 | Mock Get-ScheduledTask { return @{ |
|
255 | 263 | }) |
256 | 264 | Triggers = @(@{ |
257 | 265 | Repetition = @{ |
258 | | - Duration = $null |
| 266 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
259 | 267 | Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalHours)H" |
260 | 268 | } |
261 | 269 | CimClass = @{ |
|
314 | 322 |
|
315 | 323 | It "should update the scheduled task in the set method" { |
316 | 324 | Set-TargetResource @testParams |
317 | | - Assert-MockCalled Set-ScheduledTask |
| 325 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 326 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
318 | 327 | } |
319 | 328 | } |
320 | 329 |
|
|
358 | 367 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
359 | 368 | ScheduleType = "Once" |
360 | 369 | RepeatInterval = [DateTime]::Today.Add((New-TimeSpan -Minutes 15)) |
| 370 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
361 | 371 | ExecuteAsCredential = New-Object System.Management.Automation.PSCredential ("DEMO\RightUser", (ConvertTo-SecureString "ExamplePassword" -AsPlainText -Force)) |
362 | 372 | } |
363 | 373 |
|
|
369 | 379 | }) |
370 | 380 | Triggers = @(@{ |
371 | 381 | Repetition = @{ |
372 | | - Duration = $null |
373 | | - Interval = "PT$($testParams.RepeatInterval)M" |
| 382 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
| 383 | + Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
374 | 384 | } |
375 | 385 | CimClass = @{ |
376 | 386 | CimClassName = "MSFT_TaskTimeTrigger" |
|
391 | 401 |
|
392 | 402 | It "should update the scheduled task in the set method" { |
393 | 403 | Set-TargetResource @testParams |
394 | | - Assert-MockCalled Set-ScheduledTask |
| 404 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 405 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
395 | 406 | } |
396 | 407 | } |
397 | 408 |
|
|
402 | 413 | ActionWorkingPath = "C:\Example" |
403 | 414 | ScheduleType = "Once" |
404 | 415 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 416 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
405 | 417 | } |
406 | 418 |
|
407 | 419 | Mock Get-ScheduledTask { return @{ |
|
414 | 426 | Triggers = @(@{ |
415 | 427 | Repetition = @{ |
416 | 428 | Duration = $null |
417 | | - Interval = "PT$($testParams.RepeatInterval)M" |
| 429 | + Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
418 | 430 | } |
419 | 431 | CimClass = @{ |
420 | 432 | CimClassName = "MSFT_TaskTimeTrigger" |
|
435 | 447 |
|
436 | 448 | It "should update the scheduled task in the set method" { |
437 | 449 | Set-TargetResource @testParams |
438 | | - Assert-MockCalled Set-ScheduledTask |
| 450 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 451 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
439 | 452 | } |
440 | 453 | } |
441 | 454 |
|
|
446 | 459 | ActionArguments = "-File `"C:\something\right.ps1`"" |
447 | 460 | ScheduleType = "Once" |
448 | 461 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 462 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
449 | 463 | } |
450 | 464 |
|
451 | 465 | Mock Get-ScheduledTask { return @{ |
|
457 | 471 | }) |
458 | 472 | Triggers = @(@{ |
459 | 473 | Repetition = @{ |
460 | | - Duration = $null |
461 | | - Interval = "PT$($testParams.RepeatInterval)M" |
| 474 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
| 475 | + Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
462 | 476 | } |
463 | 477 | CimClass = @{ |
464 | 478 | CimClassName = "MSFT_TaskTimeTrigger" |
|
479 | 493 |
|
480 | 494 | It "should update the scheduled task in the set method" { |
481 | 495 | Set-TargetResource @testParams |
482 | | - Assert-MockCalled Set-ScheduledTask |
| 496 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 497 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
483 | 498 | } |
484 | 499 | } |
485 | 500 |
|
|
489 | 504 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
490 | 505 | ScheduleType = "Once" |
491 | 506 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 507 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
492 | 508 | Enable = $false |
493 | 509 | } |
494 | 510 |
|
|
501 | 517 | }) |
502 | 518 | Triggers = @(@{ |
503 | 519 | Repetition = @{ |
504 | | - Duration = $null |
505 | | - Interval = "PT$($testParams.RepeatInterval)M" |
| 520 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
| 521 | + Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
506 | 522 | } |
507 | 523 | CimClass = @{ |
508 | 524 | CimClassName = "MSFT_TaskTimeTrigger" |
|
526 | 542 |
|
527 | 543 | It "should update the scheduled task in the set method" { |
528 | 544 | Set-TargetResource @testParams |
529 | | - Assert-MockCalled Set-ScheduledTask |
| 545 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 546 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
530 | 547 | } |
531 | 548 |
|
532 | 549 | } |
|
537 | 554 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
538 | 555 | ScheduleType = "Once" |
539 | 556 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 557 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
540 | 558 | Enable = $true |
541 | 559 | } |
542 | 560 |
|
|
549 | 567 | }) |
550 | 568 | Triggers = @(@{ |
551 | 569 | Repetition = @{ |
552 | | - Duration = $null |
| 570 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
553 | 571 | Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
554 | 572 | } |
555 | 573 | CimClass = @{ |
|
579 | 597 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
580 | 598 | ScheduleType = "Once" |
581 | 599 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 600 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
582 | 601 | Enable = $false |
583 | 602 | } |
584 | 603 |
|
|
591 | 610 | }) |
592 | 611 | Triggers = @(@{ |
593 | 612 | Repetition = @{ |
594 | | - Duration = $null |
| 613 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
595 | 614 | Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
596 | 615 | } |
597 | 616 | CimClass = @{ |
|
621 | 640 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
622 | 641 | ScheduleType = "Once" |
623 | 642 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 643 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
624 | 644 | Enable = $true |
625 | 645 | } |
626 | 646 |
|
|
633 | 653 | }) |
634 | 654 | Triggers = @(@{ |
635 | 655 | Repetition = @{ |
636 | | - Duration = $null |
| 656 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
637 | 657 | Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
638 | 658 | } |
639 | 659 | CimClass = @{ |
|
658 | 678 |
|
659 | 679 | It "should update the scheduled task in the set method" { |
660 | 680 | Set-TargetResource @testParams |
661 | | - Assert-MockCalled Set-ScheduledTask |
| 681 | + Assert-MockCalled -CommandName Unregister-ScheduledTask -Times 1 |
| 682 | + Assert-Mockcalled -CommandName Register-ScheduledTask -Times 1 |
662 | 683 | } |
663 | 684 | } |
664 | 685 |
|
|
668 | 689 | ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" |
669 | 690 | ScheduleType = "Once" |
670 | 691 | RepeatInterval = [datetime]::Today + (New-TimeSpan -Minutes 15) |
| 692 | + RepetitionDuration = [datetime]::Today + (New-TimeSpan -Hours 8) |
671 | 693 | } |
672 | 694 |
|
673 | 695 | Mock Get-ScheduledTask { return @{ |
|
679 | 701 | }) |
680 | 702 | Triggers = @(@{ |
681 | 703 | Repetition = @{ |
682 | | - Duration = $null |
| 704 | + Duration = "PT$($testParams.RepetitionDuration.TimeOfDay.TotalHours)H" |
683 | 705 | Interval = "PT$($testParams.RepeatInterval.TimeOfDay.TotalMinutes)M" |
684 | 706 | } |
685 | 707 | CimClass = @{ |
|
0 commit comments