Last active 1737367223

unbloat.ps1 Raw
1# Windows 10/11 Debloat Script for Microsoft 365 Workstations
2# Run as Administrator
3
4# Create a restore point
5Enable-ComputerRestore -Drive "C:\"
6Checkpoint-Computer -Description "Before Debloat" -RestorePointType "MODIFY_SETTINGS"
7
8# Function to remove Windows Apps
9Function Remove-WindowsApps {
10 $apps = @(
11 # Games & Xbox
12 "Microsoft.Xbox.TCUI"
13 "Microsoft.XboxApp"
14 "Microsoft.XboxGameOverlay"
15 "Microsoft.XboxGamingOverlay"
16 "Microsoft.XboxIdentityProvider"
17 "Microsoft.XboxSpeechToTextOverlay"
18 "Microsoft.GamingApp"
19 "Microsoft.GamingServices"
20 "Microsoft.MicrosoftSolitaireCollection"
21
22 # Entertainment
23 "Microsoft.ZuneMusic"
24 "Microsoft.ZuneVideo"
25 "Microsoft.WindowsMixedReality.Portal"
26 "Microsoft.BingNews"
27 "Microsoft.GetHelp"
28 "Microsoft.Getstarted"
29 "Microsoft.WindowsFeedbackHub"
30
31 # Third-party bloatware
32 "king.com.CandyCrushSaga"
33 "king.com.FarmHeroesSaga"
34 "*Spotify*"
35 "*Disney*"
36 "*Netflix*"
37 "*Hulu*"
38
39 # Other unnecessary apps
40 "Microsoft.3DBuilder"
41 "Microsoft.Microsoft3DViewer"
42 "Microsoft.MixedReality.Portal"
43 "Microsoft.SkypeApp"
44 "Microsoft.WindowsAlarms"
45 "Microsoft.WindowsCamera"
46 "Microsoft.WindowsMaps"
47 "Microsoft.WindowsSoundRecorder"
48 "Microsoft.YourPhone"
49 "Microsoft.MicrosoftOfficeHub" # Not needed with M365 installed
50 "Microsoft.People"
51 "Microsoft.Windows.Photos"
52 "Microsoft.WindowsCalculator"
53 )
54
55 ForEach ($app in $apps) {
56 Write-Host "Removing: $app"
57 Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -ErrorAction SilentlyContinue
58 Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $app | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
59 }
60}
61
62# Function to disable unnecessary services
63Function Disable-UnwantedServices {
64 $services = @(
65 "XblAuthManager" # Xbox Live Auth Manager
66 "XblGameSave" # Xbox Live Game Save
67 "XboxNetApiSvc" # Xbox Live Networking
68 "WMPNetworkSvc" # Windows Media Player Network
69 "RetailDemo" # Retail Demo Service
70 "WerSvc" # Windows Error Reporting
71 "wisvc" # Windows Insider Service
72 "lfsvc" # Geolocation Service
73 "MapsBroker" # Downloaded Maps Manager
74 "WSearch" # Windows Search (can be re-enabled if needed)
75 "DiagTrack" # Connected User Experiences and Telemetry
76 "SysMain" # Superfetch
77 "iphlpsvc" # IP Helper (IPv6 components)
78 "WbioSrvc" # Windows Biometric Service
79 "FontCache" # Windows Font Cache Service
80 "TabletInputService" # Touch Keyboard and Handwriting Panel Service
81 )
82
83 ForEach ($service in $services) {
84 Write-Host "Disabling service: $service"
85 Set-Service -Name $service -StartupType Disabled -ErrorAction SilentlyContinue
86 Stop-Service -Name $service -Force -ErrorAction SilentlyContinue
87 }
88}
89
90# Function to disable telemetry and other unnecessary features
91Function Disable-Telemetry {
92 # Disable telemetry
93 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
94
95 # Disable Cortana
96 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -Type DWord -Value 0
97
98 # Disable Consumer Features
99 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Type DWord -Value 1
100
101 # Disable Suggest Apps
102 Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -Type DWord -Value 0
103
104 # Disable Advertising ID
105 Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -Type DWord -Value 0
106}
107
108# Function to optimize Windows performance
109Function Optimize-WindowsPerformance {
110 Write-Host "Optimizing system performance..."
111
112 # Disable visual effects
113 Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Type DWord -Value 2
114
115 # Disable animations
116 Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value "0"
117
118 # Optimize for performance
119 $path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\AnimateMinMax"
120 If (!(Test-Path $path)) {
121 New-Item -Path $path -Force | Out-Null
122 }
123 Set-ItemProperty -Path $path -Name "Enabled" -Type DWord -Value 0
124
125 # Disable Transparency
126 Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "EnableTransparency" -Type DWord -Value 0
127
128 # Set virtual memory (page file)
129 $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
130 $computersys.AutomaticManagedPagefile = $False
131 $computersys.Put()
132 $pagefile = Get-WmiObject -Query "Select * From Win32_PageFileSetting Where Name like '%pagefile.sys'"
133 $pagefile.InitialSize = 4096 # 4GB initial size
134 $pagefile.MaximumSize = 8192 # 8GB maximum size
135 $pagefile.Put()
136
137 # Disable Memory Compression
138 Disable-MMAgent -mc
139
140 # Disable Fast Startup
141 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name "HiberbootEnabled" -Type DWord -Value 0
142}
143
144# Function to disable hibernation and optimize power settings
145Function Optimize-PowerSettings {
146 Write-Host "Optimizing power settings..."
147
148 # Disable hibernation
149 powercfg /hibernate off
150
151 # Set power plan to high performance
152 powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
153
154 # Disable sleep
155 powercfg /change standby-timeout-ac 0
156 powercfg /change standby-timeout-dc 0
157
158 # Disable monitor timeout
159 powercfg /change monitor-timeout-ac 0
160 powercfg /change monitor-timeout-dc 0
161
162 # Disable disk timeout
163 powercfg /change disk-timeout-ac 0
164 powercfg /change disk-timeout-dc 0
165
166 # Disable hybrid sleep
167 powercfg /change hibernate-timeout-ac 0
168 powercfg /change hibernate-timeout-dc 0
169}
170
171# Function to optimize network settings
172Function Optimize-NetworkSettings {
173 Write-Host "Optimizing network settings..."
174
175 # Disable IPv6
176 Disable-NetAdapterBinding -Name "*" -ComponentID "ms_tcpip6"
177
178 # Set DNS Client service to automatic
179 Set-Service "Dnscache" -StartupType Automatic
180
181 # Disable NetBIOS over TCP/IP
182 $adapters = Get-WmiObject Win32_NetworkAdapterConfiguration
183 foreach($adapter in $adapters) {
184 $adapter.SetTcpipNetbios(2)
185 }
186
187 # Optimize TCP/IP settings
188 netsh int tcp set global autotuninglevel=normal
189 netsh int tcp set global chimney=enabled
190 netsh int tcp set global dca=enabled
191 netsh int tcp set global netdma=enabled
192}
193
194# Main execution
195Write-Host "Starting Windows Debloat and Optimization Script..."
196Write-Host "Creating System Restore Point..."
197
198# Execute functions
199Remove-WindowsApps
200Disable-UnwantedServices
201Disable-Telemetry
202Optimize-WindowsPerformance
203Optimize-PowerSettings
204Optimize-NetworkSettings
205
206# Clear temp files
207Remove-Item -Path "C:\Windows\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue
208Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue
209
210Write-Host "Cleanup and optimization complete. Please restart your computer for changes to take effect."
211
212# Optional: Force restart
213# Restart-Computer -Force