From 184fe22a351dbfe4a9c1e7bc731a06e4c2d52c02 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Thu, 30 Apr 2026 15:16:27 -0500 Subject: [PATCH] Cleanup: Delete all Scheduled Tasks related things (#4435) * Delete functions/private/Set-WinUtilScheduledTask.ps1 * Update Invoke-WinUtilTweaks.ps1 * Update Invoke-WinUtilCurrentSystem.ps1 * waste of time --------- Co-authored-by: Gabi <218829269+GabiNun2@users.noreply.github.com> --- docs/content/dev/architecture.md | 8 ---- .../private/Invoke-WinUtilCurrentSystem.ps1 | 19 +-------- functions/private/Invoke-WinUtilTweaks.ps1 | 8 ---- .../private/Set-WinUtilScheduledTask.ps1 | 42 ------------------- pester/configs.Tests.ps1 | 4 -- 5 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 functions/private/Set-WinUtilScheduledTask.ps1 diff --git a/docs/content/dev/architecture.md b/docs/content/dev/architecture.md index fb0fb504..8a943387 100644 --- a/docs/content/dev/architecture.md +++ b/docs/content/dev/architecture.md @@ -380,13 +380,6 @@ Update UI "Value": "0", "OriginalValue": "1" } - ], - "ScheduledTask": [ - { - "Name": "Microsoft\\Windows\\Autochk\\Proxy", - "State": "Disabled", - "OriginalState": "Enabled" - } ] } } @@ -397,7 +390,6 @@ Update UI - `Description`: What it does - `category`: Essential/Advanced/Customize - `registry`: Registry changes to make -- `ScheduledTask`: Scheduled tasks to modify - `service`: Services to change - `OriginalValue/State`: For undo functionality diff --git a/functions/private/Invoke-WinUtilCurrentSystem.ps1 b/functions/private/Invoke-WinUtilCurrentSystem.ps1 index ebcdc38f..2d2bf894 100644 --- a/functions/private/Invoke-WinUtilCurrentSystem.ps1 +++ b/functions/private/Invoke-WinUtilCurrentSystem.ps1 @@ -44,21 +44,18 @@ Function Invoke-WinUtilCurrentSystem { if ($CheckBox -eq "tweaks") { if (!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)} - $ScheduledTasks = Get-ScheduledTask $sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object { $Config = $psitem.Name - #WPFEssTweaksTele $entry = $sync.configs.tweaks.$Config $registryKeys = $entry.registry - $scheduledtaskKeys = $entry.scheduledtask $serviceKeys = $entry.service $appxKeys = $entry.appx $invokeScript = $entry.InvokeScript $entryType = $entry.Type - if ($registryKeys -or $scheduledtaskKeys -or $serviceKeys) { + if ($registryKeys -or $serviceKeys) { $Values = @() if ($entryType -eq "Toggle") { @@ -103,20 +100,6 @@ Function Invoke-WinUtilCurrentSystem { } } - Foreach ($tweaks in $scheduledtaskKeys) { - Foreach ($tweak in $tweaks) { - $task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"} - - if ($task) { - $actualValue = $task.State - $expectedValue = $tweak.State - if ($expectedValue -ne $actualValue) { - $values += $False - } - } - } - } - Foreach ($tweaks in $serviceKeys) { Foreach ($tweak in $tweaks) { $Service = Get-Service -Name $tweak.Name diff --git a/functions/private/Invoke-WinUtilTweaks.ps1 b/functions/private/Invoke-WinUtilTweaks.ps1 index 2c8a6691..bb5a755c 100644 --- a/functions/private/Invoke-WinUtilTweaks.ps1 +++ b/functions/private/Invoke-WinUtilTweaks.ps1 @@ -25,7 +25,6 @@ function Invoke-WinUtilTweaks { if($undo) { $Values = @{ Registry = "OriginalValue" - ScheduledTask = "OriginalState" Service = "OriginalType" ScriptType = "UndoScript" } @@ -33,18 +32,11 @@ function Invoke-WinUtilTweaks { } else { $Values = @{ Registry = "Value" - ScheduledTask = "State" Service = "StartupType" OriginalService = "OriginalType" ScriptType = "InvokeScript" } } - if($sync.configs.tweaks.$CheckBox.ScheduledTask) { - $sync.configs.tweaks.$CheckBox.ScheduledTask | ForEach-Object { - Write-Debug "$($psitem.Name) and state is $($psitem.$($values.ScheduledTask))" - Set-WinUtilScheduledTask -Name $psitem.Name -State $psitem.$($values.ScheduledTask) - } - } if($sync.configs.tweaks.$CheckBox.service) { Write-Debug "KeepServiceStartup is $KeepServiceStartup" $sync.configs.tweaks.$CheckBox.service | ForEach-Object { diff --git a/functions/private/Set-WinUtilScheduledTask.ps1 b/functions/private/Set-WinUtilScheduledTask.ps1 deleted file mode 100644 index 8cff7aa4..00000000 --- a/functions/private/Set-WinUtilScheduledTask.ps1 +++ /dev/null @@ -1,42 +0,0 @@ -function Set-WinUtilScheduledTask { - <# - - .SYNOPSIS - Enables/Disables the provided Scheduled Task - - .PARAMETER Name - The path to the Scheduled Task - - .PARAMETER State - The State to set the Task to - - .EXAMPLE - Set-WinUtilScheduledTask -Name "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" -State "Disabled" - - #> - param ( - $Name, - $State - ) - - try { - if($State -eq "Disabled") { - Write-Host "Disabling Scheduled Task $Name" - Disable-ScheduledTask -TaskName $Name -ErrorAction Stop - } - if($State -eq "Enabled") { - Write-Host "Enabling Scheduled Task $Name" - Enable-ScheduledTask -TaskName $Name -ErrorAction Stop - } - } catch [System.Exception] { - if($psitem.Exception.Message -like "*The system cannot find the file specified*") { - Write-Warning "Scheduled Task $Name was not found." - } else { - Write-Warning "Unable to set $Name due to unhandled exception." - Write-Warning $psitem.Exception.Message - } - } catch { - Write-Warning "Unable to run script for $name due to unhandled exception." - Write-Warning $psitem.Exception.StackTrace - } -} diff --git a/pester/configs.Tests.ps1 b/pester/configs.Tests.ps1 index f8e55c44..4e80cb1f 100644 --- a/pester/configs.Tests.ps1 +++ b/pester/configs.Tests.ps1 @@ -65,10 +65,6 @@ Describe "Config Files" -ForEach @( @{ name = "service" value = "OriginalType" - }, - @{ - name = "ScheduledTask" - value = "OriginalState" } ) Foreach ($original in $Originals) {