-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
Optimize-ServicesRunning.ps1
119 lines (106 loc) · 7.79 KB
/
Optimize-ServicesRunning.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
108
109
110
111
112
113
114
115
116
117
118
119
Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\Get-HardwareInfo.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\Title-Templates.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\debloat-helper\Set-ServiceStartup.psm1"
# Adapted from: https://youtu.be/qWESrvP_uU8
# Adapted from: https://github.com/ChrisTitusTech/win10script
# Adapted from: https://gist.github.com/matthewjberger/2f4295887d6cb5738fa34e597f457b7f
# Adapted from: https://github.com/Sycnex/Windows10Debloater
function Optimize-ServicesRunning() {
[CmdletBinding()]
param (
[Switch] $Revert
)
$IsSystemDriveSSD = $(Get-OSDriveType) -eq "SSD"
$EnableServicesOnSSD = @("SysMain", "WSearch")
# Services which will be totally disabled
$ServicesToDisabled = @(
"DiagTrack" # DEFAULT: Automatic | Connected User Experiences and Telemetry
"diagnosticshub.standardcollector.service" # DEFAULT: Manual | Microsoft (R) Diagnostics Hub Standard Collector Service
"dmwappushservice" # DEFAULT: Manual | Device Management Wireless Application Protocol (WAP)
"Fax" # DEFAULT: Manual | Fax Service
"fhsvc" # DEFAULT: Manual | File History Service
"GraphicsPerfSvc" # DEFAULT: Manual | Graphics performance monitor service
"HomeGroupListener" # NOT FOUND (Win 10+)| HomeGroup Listener
"HomeGroupProvider" # NOT FOUND (Win 10+)| HomeGroup Provider
"lfsvc" # DEFAULT: Manual | Geolocation Service
"MapsBroker" # DEFAULT: Automatic | Downloaded Maps Manager
"PcaSvc" # DEFAULT: Automatic | Program Compatibility Assistant (PCA)
"RemoteAccess" # DEFAULT: Disabled | Routing and Remote Access
"RemoteRegistry" # DEFAULT: Disabled | Remote Registry
"RetailDemo" # DEFAULT: Manual | The Retail Demo Service controls device activity while the device is in retail demo mode.
"SysMain" # DEFAULT: Automatic | SysMain / Superfetch (100% Disk usage on HDDs)
"TrkWks" # DEFAULT: Automatic | Distributed Link Tracking Client
"WSearch" # DEFAULT: Automatic | Windows Search (100% Disk usage on HDDs)
# - Services which cannot be disabled (and shouldn't)
#"wscsvc" # DEFAULT: Automatic | Windows Security Center Service
#"WdNisSvc" # DEFAULT: Manual | Windows Defender Network Inspection Service
)
# Making the services to run only when needed as 'Manual' | Remove the # to set to Manual
$ServicesToManual = @(
"BITS" # DEFAULT: Manual | Background Intelligent Transfer Service
"edgeupdate" # DEFAULT: Automatic | Microsoft Edge Update Service
"edgeupdatem" # DEFAULT: Manual | Microsoft Edge Update Service²
"FontCache" # DEFAULT: Automatic | Windows Font Cache
"PhoneSvc" # DEFAULT: Manual | Phone Service (Manages the telephony state on the device)
"SCardSvr" # DEFAULT: Manual | Smart Card Service
"stisvc" # DEFAULT: Automatic | Windows Image Acquisition (WIA) Service
"WbioSrvc" # DEFAULT: Manual | Windows Biometric Service (required for Fingerprint reader / Facial detection)
"wisvc" # DEFAULT: Manual | Windows Insider Program Service
"WMPNetworkSvc" # DEFAULT: Manual | Windows Media Player Network Sharing Service
"WpnService" # DEFAULT: Automatic | Windows Push Notification Services (WNS)
<# Bluetooth services #>
"BTAGService" # DEFAULT: Manual | Bluetooth Audio Gateway Service
"BthAvctpSvc" # DEFAULT: Manual | AVCTP Service
"bthserv" # DEFAULT: Manual | Bluetooth Support Service
"RtkBtManServ" # DEFAULT: Automatic | Realtek Bluetooth Device Manager Service
<# Diagnostic Services #>
"DPS" # DEFAULT: Automatic | Diagnostic Policy Service
"WdiServiceHost" # DEFAULT: Manual | Diagnostic Service Host
"WdiSystemHost" # DEFAULT: Manual | Diagnostic System Host
<# Network Services #>
"iphlpsvc" # DEFAULT: Automatic | IP Helper Service (IPv6 (6to4, ISATAP, Port Proxy and Teredo) and IP-HTTPS)
"lmhosts" # DEFAULT: Manual | TCP/IP NetBIOS Helper
#"NetTcpPortSharing" # DEFAULT: Disabled | Net.Tcp Port Sharing Service
"SharedAccess" # DEFAULT: Manual | Internet Connection Sharing (ICS)
<# Telemetry Services #>
"Wecsvc" # DEFAULT: Manual | Windows Event Collector Service
"WerSvc" # DEFAULT: Manual | Windows Error Reporting Service
<# Xbox services #>
"XblAuthManager" # DEFAULT: Manual | Xbox Live Auth Manager
"XblGameSave" # DEFAULT: Manual | Xbox Live Game Save
"XboxGipSvc" # DEFAULT: Manual | Xbox Accessory Management Service
"XboxNetApiSvc" # DEFAULT: Manual | Xbox Live Networking Service
<# Printer services #>
#"PrintNotify" # DEFAULT: Manual | WARNING! REMOVING WILL TURN PRINTING LESS MANAGEABLE | Printer Extensions and Notifications
#"Spooler" # DEFAULT: Automatic | WARNING! REMOVING WILL DISABLE PRINTING | Print Spooler
<# Wi-Fi services #>
#"WlanSvc" # DEFAULT: Manual (No Wi-Fi devices) / Automatic (Wi-Fi devices) | WARNING! REMOVING WILL DISABLE WI-FI | WLAN AutoConfig
<# 3rd Party Services #>
"gupdate" # DEFAULT: Automatic | Google Update Service
"gupdatem" # DEFAULT: Manual | Google Update Service²
)
$ServicesToAutomatic = @(
"ndu" # DEFAULT: Automatic | Windows Network Data Usage Monitoring Driver (Shows network usage per-process on Task Manager)
)
Write-Title "Services tweaks"
Write-Section "Disabling services from Windows"
If ($Revert) {
Write-Status -Types "*", "Service" -Status "Reverting the tweaks is set to '$Revert'." -Warning
Set-ServiceStartup -State 'Manual' -Services $ServicesToDisabled -Filter $EnableServicesOnSSD
} Else {
Set-ServiceStartup -State 'Disabled' -Services $ServicesToDisabled -Filter $EnableServicesOnSSD
}
Write-Section "Enabling services from Windows"
If ($IsSystemDriveSSD -or $Revert) {
Set-ServiceStartup -State 'Automatic' -Services $EnableServicesOnSSD
}
Set-ServiceStartup -State 'Manual' -Services $ServicesToManual
Set-ServiceStartup -State 'Automatic' -Services $ServicesToAutomatic
}
# List all services:
#Get-Service | Select-Object StartType, Status, Name, DisplayName, ServiceType | Sort-Object StartType, Status, Name | Format-Table
If (!$Revert) {
Optimize-ServicesRunning # Enable essential Services and Disable bloating Services
} Else {
Optimize-ServicesRunning -Revert
}