@@ -510,7 +510,33 @@ Describe 'Functions' {
510
510
It ' Restart-ComputerWithDelay' {
511
511
}
512
512
}
513
-
513
+ Context ' Test SetScheduledTask' {
514
+ BeforeAll {
515
+ $scheduledTasks = Get-ScheduledTask | Where-Object { $_.TaskPath -notlike " *\Microsoft\Windows*" -and $_.State -ne " Disabled" -and $_.state -ne " Running" }
516
+ SetScheduledTask - op " disable" - scheduledTasks $scheduledTasks
517
+ }
518
+ It ' Should disabled tasks' {
519
+ # Disable tasks that are ready to run
520
+ $afterDisable = Get-ScheduledTask | Where-Object { $_.TaskPath -notlike " *\Microsoft\Windows*" -and $_.State -eq " Disabled" }
521
+ # Compare $scheduledTasks and $afterDisable state should not be equal
522
+ $scheduledTasks | ForEach-Object {
523
+ $task = $_
524
+ # Check that the task is disabled
525
+ $afterDisable | Where-Object { $_.TaskName -eq $task.TaskName -and $_.State -eq " Disabled" } | Should -Not - BeNullOrEmpty
526
+ }
527
+ }
528
+ It ' Should Enable tasks' {
529
+ SetScheduledTask - op " enable" - scheduledTasks $scheduledTasks
530
+ # Validate that the tasks are enabled
531
+ $afterEnable = Get-ScheduledTask | Where-Object { $_.TaskPath -notlike " *\Microsoft\Windows*" -and $_.State -eq " Ready" }
532
+ # Compare $scheduledTasks and $afterDisable state should not be equal
533
+ $scheduledTasks | ForEach-Object {
534
+ $task = $_
535
+ # Check that the task is disabled
536
+ $afterEnable | Where-Object { $_.TaskName -eq $task.TaskName -and $_.State -eq " Ready" } | Should -Not - BeNullOrEmpty
537
+ }
538
+ }
539
+ }
514
540
Context ' Validates that the Registry Hive Permissions are correct, given a username' {
515
541
It ' Should return true when a users ntfs permissions are correct' {
516
542
$datUserTrue = " ADMU_dat_" + -join ((65 .. 90 ) + (97 .. 122 ) | Get-Random - Count 5 | ForEach-Object { [char ]$_ })
0 commit comments