forked from LeDragoX/Win-Debloat-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptimize-scheduled-tasks.ps1
107 lines (84 loc) · 5.71 KB
/
optimize-scheduled-tasks.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
# Adapted from this Baboo video: https://youtu.be/qWESrvP_uU8
# Adapted from this ChrisTitus script: https://github.com/ChrisTitusTech/win10script
# Adapted from this matthewjberger's script: https://gist.github.com/matthewjberger/2f4295887d6cb5738fa34e597f457b7f
# Adapted from this Sycnex script: https://github.com/Sycnex/Windows10Debloater
# Adapted from this kalaspuffar/Daniel Persson script: https://github.com/kalaspuffar/windows-debloat
function Optimize-ScheduledTasks() {
Write-Title -Text "Scheduled Tasks tweaks"
Write-Section -Text "Disabling Scheduled Tasks"
# Took from: https://docs.microsoft.com/pt-br/windows-server/remote/remote-desktop-services/rds-vdi-recommendations#task-scheduler
$DisableScheduledTasks = @(
"\Microsoft\Office\OfficeTelemetryAgentLogOn"
"\Microsoft\Office\OfficeTelemetryAgentFallBack"
"\Microsoft\Office\Office 15 Subscription Heartbeat"
"\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
"\Microsoft\Windows\Application Experience\ProgramDataUpdater"
"\Microsoft\Windows\Application Experience\StartupAppTask"
"\Microsoft\Windows\Autochk\Proxy"
"\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" # Recommended state for VDI use
"\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" # Recommended state for VDI use
"\Microsoft\Windows\Customer Experience Improvement Program\Uploader"
"\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" # Recommended state for VDI use
"\Microsoft\Windows\Defrag\ScheduledDefrag" # Recommended state for VDI use
"\Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector"
"\Microsoft\Windows\Location\Notifications" # Recommended state for VDI use
"\Microsoft\Windows\Location\WindowsActionDialog" # Recommended state for VDI use
"\Microsoft\Windows\Maintenance\WinSAT" # Recommended state for VDI use
"\Microsoft\Windows\Maps\MapsToastTask" # Recommended state for VDI use
"\Microsoft\Windows\Maps\MapsUpdateTask" # Recommended state for VDI use
"\Microsoft\Windows\Mobile Broadband Accounts\MNO Metadata Parser" # Recommended state for VDI use
"\Microsoft\Windows\Power Efficiency Diagnostics\AnalyzeSystem" # Recommended state for VDI use
"\Microsoft\Windows\Retail Demo\CleanupOfflineContent" # Recommended state for VDI use
"\Microsoft\Windows\Shell\FamilySafetyMonitor" # Recommended state for VDI use
"\Microsoft\Windows\Shell\FamilySafetyRefreshTask" # Recommended state for VDI use
"\Microsoft\Windows\Shell\FamilySafetyUpload"
"\Microsoft\Windows\Windows Media Sharing\UpdateLibrary" # Recommended state for VDI use
)
ForEach ($ScheduledTask in $DisableScheduledTasks) {
If (Get-ScheduledTaskInfo -TaskName $ScheduledTask -ErrorAction SilentlyContinue) {
Write-Host "$($EnableStatus[0]) the $ScheduledTask Task..."
Invoke-Expression "$($Commands[0])"
}
Else {
Write-Warning "[?][TaskScheduler] $ScheduledTask was not found."
}
}
Write-Section -Text "Enabling Scheduled Tasks"
$EnableScheduledTasks = @(
"\Microsoft\Windows\RecoveryEnvironment\VerifyWinRE" # It's about the Recovery before starting Windows, with Diagnostic tools and Troubleshooting when your PC isn't healthy, need this ON.
"\Microsoft\Windows\Windows Error Reporting\QueueReporting" # Windows Error Reporting event, needed to improve compatibility with your hardware
)
ForEach ($ScheduledTask in $EnableScheduledTasks) {
If (Get-ScheduledTaskInfo -TaskName $ScheduledTask -ErrorAction SilentlyContinue) {
Write-Host "[+][TaskScheduler] Enabling the $ScheduledTask Task..."
Get-ScheduledTask -TaskName "$ScheduledTask".Split("\")[-1] | Where-Object State -Like "Disabled" | Enable-ScheduledTask
}
Else {
Write-Warning "[?][TaskScheduler] $ScheduledTask was not found."
}
}
}
function Main() {
$EnableStatus = @(
"[-][TaskScheduler] Disabling",
"[+][TaskScheduler] Enabling"
)
$Commands = @(
{ Get-ScheduledTask -TaskName "$ScheduledTask".Split("\")[-1] | Where-Object State -Like "R*" | Disable-ScheduledTask }, # R* = Ready/Running Tasks
{ Get-ScheduledTask -TaskName "$ScheduledTask".Split("\")[-1] | Where-Object State -Like "Disabled" | Enable-ScheduledTask }
)
if (($Revert)) {
Write-Warning "[<][TaskScheduler] Reverting: $Revert."
$EnableStatus = @(
"[<][TaskScheduler] Re-Enabling",
"[<][TaskScheduler] Re-Disabling"
)
$Commands = @(
{ Get-ScheduledTask -TaskName "$ScheduledTask".Split("\")[-1] | Where-Object State -Like "Disabled" | Enable-ScheduledTask },
{ Get-ScheduledTask -TaskName "$ScheduledTask".Split("\")[-1] | Where-Object State -Like "R*" | Disable-ScheduledTask } # R* = Ready/Running Tasks
)
}
Optimize-ScheduledTasks # Disable Scheduled Tasks that causes slowdowns
}
Main