Skip to content

Commit cb16c2b

Browse files
committed
Functions Test
1 parent 9d32e17 commit cb16c2b

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

jumpcloud-ADMU/Powershell/Tests/Functions.Tests.ps1

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,33 @@ Describe 'Functions' {
510510
It 'Restart-ComputerWithDelay' {
511511
}
512512
}
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+
}
514540
Context 'Validates that the Registry Hive Permissions are correct, given a username' {
515541
It 'Should return true when a users ntfs permissions are correct' {
516542
$datUserTrue = "ADMU_dat_" + -join ((65..90) + (97..122) | Get-Random -Count 5 | ForEach-Object { [char]$_ })

0 commit comments

Comments
 (0)