-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow-cleanup.ps1
247 lines (196 loc) · 13.8 KB
/
window-cleanup.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
function registrySet($Path, $Name, $Type = "Dword", $Value = 0) {
if (!(Test-Path $Path)) {
# Maybe instead of create, use -force with set-itemproperty?
New-Item -Path $Path | Out-Null
}
$key = get-item $Path
if ($null -ne $key.getValue($Name)) {
Set-ItemProperty -Path $Path -Name $Name -Value $Value | Out-Null
}
else {
New-ItemProperty -Path $Path -Name $Name -PropertyType $Type -Value $Value | Out-Null
}
}
function appInstall($filename, $uri) {
$Installer = $env:TEMP + "\" + $filename;
Invoke-WebRequest $uri -OutFile $Installer;
Start-Process -FilePath $Installer -Args "/s /silent /install" -Verb RunAs -Wait;
itemRemove -Path $Installer;
}
function appRemove($package) {
Write-Host "Uninstall user app ${package}"
try {
Remove-AppxPackage -Package $package -AllUsers -ErrorAction Continue | Out-Null
}
catch {
Write-Host "Failed to uninstall user app ${package}" $_.Exception.Message
}
}
function appRemoveProvisioned($packageName) {
Write-Host "Uninstall image app ${packageName}"
try {
Remove-ProvisionedAppxPackage -PackageName $packageName -Online -AllUsers -ErrorAction Continue | Out-Null
}
catch {
Write-Host "Failed to uninstall image app ${packageName}" $_.Exception.Message
}
}
function appRemoveRegex($regex) {
Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match $regex } | ForEach-Object { appRemoveProvisioned -PackageName $_.PackageName }
Get-AppxPackage | Where-Object { $_.PackageName -match $regex } | ForEach-Object { appRemove -Package $_.PackageFullName }
}
function serviceDisable($Name){
Stop-Service -Name $Name -WarningAction SilentlyContinue | Out-Null
Set-Service -Name $Name -StartupType "Disabled" | Out-Null
}
function itemRemove($path){
Remove-Item $path -force -recurse -ErrorAction SilentlyContinue
}
Write-Host "Ensure Admin mode"
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
Write-Host "Switch to admin"
Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
exit;
}
Write-Host "Create Restore Point"
Enable-ComputerRestore -Drive "C:\"
Checkpoint-Computer -Description "RestorePoint1" -RestorePointType "MODIFY_SETTINGS"
Write-Host "Uninstall Cortana"
registrySet -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' -Name AllowCortana -Value 0
appRemoveRegex -regex Microsoft.549981C3F5F10
Write-Host "Uninstall Spotify"
appRemoveRegex -regex "spotify"
Write-Host "Uninstall microsoft apps"
@( "Microsoft.BingNews", "Microsoft.GetHelp", "Microsoft.Getstarted", "Microsoft.Microsoft3DViewer", "Microsoft.MicrosoftOfficeHub", "Microsoft.NetworkSpeedTest", "Microsoft.News", "Microsoft.Office.Lens", "Microsoft.Office.OneNote",
"Microsoft.Office.Sway", "Microsoft.OneConnect", "Microsoft.People", "Microsoft.Print3D", "Microsoft.Office.Todo.List", "Microsoft.Whiteboard", "Microsoft.WindowsAlarms", "Microsoft.WindowsFeedbackHub", "Microsoft.WindowsMaps",
"Microsoft.BingWeather", "Microsoft.MicrosoftSolitaireCollection", "Microsoft.MixedReality.Portal", "Microsoft.Wallet", "Microsoft.YourPhone", "Microsoft.XboxGameCallableUI", "Microsoft.MicrosoftTreasureHunt",
"Microsoft.Windows.NarratorQuickStart", "Microsoft.WindowsSoundRecorder", "Microsoft.ZuneMusic", "Microsoft.ZuneVideo", "Microsoft.3DBuilder"
) | ForEach-Object { appRemoveRegex -regex $_ }
Write-Host "Uninstall advertised apps"
@( "EclipseManager", "ActiproSoftwareLLC", "AdobeSystemsIncorporated.AdobePhotoshopExpress", "Duolingo-LearnLanguagesforFree", "PandoraMediaInc", "CandyCrush",
"BubbleWitch3Saga", "Wunderlist", "Flipboard", "Twitter", "Facebook", "Minecraft", "Royal Revolt", "Sway", "Dolby"
) | ForEach-Object { appRemoveRegex -regex $_ }
Write-Host "Uninstall Xbox"
@( "XblAuthManager", "XblGameSave", "XboxGipSvc", "XboxNetApiSvc" ) | ForEach-Object { serviceDisable -Name $_ }
appRemoveRegex -regex "Microsoft.GamingServices"
appRemoveRegex -regex "xbox"
registrySet -Path "HKLM:\SYSTEM\CurrentControlSet\Services\xbgm" -Name "Start" -Value 4
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" -Name "AppCaptureEnabled"
registrySet -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled"
registrySet -Path "HKCU:\Software\Microsoft\GameBar" -Name "ShowGameModeNotifications"
registrySet -Path "HKCU:\Software\Microsoft\GameBar" -Name "AutoGameModeEnabled"
registrySet -Path "HKCU:\Software\Microsoft\GameBar" -Name "ShowStartupPanel"
registrySet -Path "HKCU:\Software\Microsoft\GameBar" -Name "UseNexusForGameBarEnabled"
registrySet -Path "HKLM:\SYSTEM\CurrentControlSet\Services\xbgm" -Name "Start" -Value 4
registrySet -Path "HKLM:\SOFTWARE\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Gaming.GameBar.PresenceServer.Internal.PresenceWriter" -Name "ActivationType"
# TODO Doesn't work
# Write-Host "Uninstall what's possible from the pinned in Start Menu"
# (New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ForEach-Object { $_.Verbs() } | Where-Object { $_.Name -match 'Uninstall' } | ForEach-Object { $_.DoIt() }
# TODO Doesn't work
# Write-Host "Unpin what's remaining from the pinnsed in Start Menu"
# (New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ForEach-Object { $_.Verbs() } | Where-Object { $_.Name -match 'Un.*pin from Start' } | ForEach-Object { $_.DoIt() }
Write-Host "Disable Task View button"
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton"
Write-Host "Changing default Explorer view to This PC..."
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -Value 1
Write-Host "Show known file extensions"
registrySet -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt"
Write-Host "Disable People icon on Taskbar"
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand"
Write-Host "Disable suggestions in the Start Menu"
registrySet -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled"
Write-Host "Disable bloatware reinstall"
registrySet -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Value 1
Write-Host "Disable Bing Search in the Start Menu search"
registrySet -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "DisableSearchBoxSuggestions" -Value 1
Write-Host "Show all tray icons"
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "EnableAutoTray"
Write-Host "Never join taskbar items"
registrySet -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -Value 1
Write-Host "Show all icons on the desktop"
@(
"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", "{59031a47-3f72-44a7-89c5-5595fe6b30ee}", "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", "{645FF040-5081-101B-9F08-00AA002F954E}"
) | ForEach-Object { registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name $_ }
Write-Host "Hide searchbar"
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "SearchBoxTaskbarMode"
Write-Host "Showing file operations details..."
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Name "EnthusiastMode" -Value 1
Write-Host "Best Performance settings"
registrySet -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 0
registrySet -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 10
registrySet -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](144, 18, 3, 128, 16, 0, 0, 0))
registrySet -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 0
registrySet -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay"
registrySet -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect"
registrySet -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewShadow"
registrySet -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAnimations"
registrySet -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Value 3
registrySet -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "EnableAeroPeek"
Write-Host "Disable Activity History"
registrySet -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableActivityFeed"
registrySet -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "PublishUserActivities"
registrySet -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "UploadUserActivities"
Write-Host "Disabling Feedback..."
registrySet -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod"
registrySet -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "DoNotShowFeedbackNotifications" -Value 1
Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" -ErrorAction SilentlyContinue | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" -ErrorAction SilentlyContinue | Out-Null
Write-Host "Disable advertising ID"
registrySet -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" -Name "DisabledByGroupPolicy" -Value 1
Write-Host "Disable error reporting"
registrySet -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -Value 1
Disable-ScheduledTask -TaskName "Microsoft\Windows\Windows Error Reporting\QueueReporting" | Out-Null
Write-Host "Stop and disable Diagnostics Tracking Service"
serviceDisable -Name "DiagTrack"
Write-Host "Turn off Data Collection via AllowTelemtry"
registrySet -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry"
Write-Host "Disable automatic Maps update"
registrySet -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled"
Write-Host "Disable Weather & Interests"
registrySet - Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds" - Name "ShellFeedsTaskbarViewMode " -Value 2
Write-Host "Disable Hibernation"
registrySet -Path "HKLM:\System\CurrentControlSet\Control\Session Manager\Power" -Name "HibernteEnabled"
registrySet -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowHibernateOption"
Write-Host "Driver updates through Windows Update"
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue
# Write-Host "Install browsers - ${$env:TEMP}"
# appInstall -filename "chrome_installer.exe" -uri "http://dl.google.com/chrome/install/375.126/chrome_installer.exe"
# appInstall -filename "firefox.exe" -uri "https://download.mozilla.org/?product=firefox-msi-latest-ssl&os=win64&lang=en-US"
# appInstall -filename "brave_installer-x64.exe" -uri "https://brave-browser-downloads.s3.brave.com/latest/brave_installer-x64.exe"
Write-Host "Uninstall OneDrive - takes time"
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive")) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" | Out-Null }
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Type DWord -Value 1
Stop-Process -Name "OneDrive" -ErrorAction SilentlyContinue
Start-Sleep -s 2
$onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
If (!(Test-Path $onedrive)) { $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe" }
Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
Start-Sleep -s 2
Stop-Process -Name "explorer" -ErrorAction SilentlyContinue
Start-Sleep -s 2
itemRemove -Path "$env:USERPROFILE\OneDrive"
itemRemove -Path "$env:LOCALAPPDATA\Microsoft\OneDrive"
itemRemove -Path "$env:PROGRAMDATA\Microsoft OneDrive"
itemRemove -Path "$env:SYSTEMDRIVE\OneDriveTemp"
If (!(Test-Path "HKCR:")) { New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null }
itemRemove -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
itemRemove -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
Write-Host "Language - takes time"
if ((Get-InstalledLanguage | ForEach-Object { $_.LanguageId }) -notcontains "pl-PL" ) { Install-Language pl-PL }
Set-WinSystemLocale -SystemLocale pl-PL
Set-SystemPreferredUILanguage pl-PL
Write-Host "Cleanup temp folders"
itemRemove -Path @( "C:\Windows\Temp\*", "C:\Windows\Prefetch\*", "C:\Documents and Settings\*\Local Settings\temp\*", "C:\Users\*\Appdata\Local\Temp\*" )
Write-Host "Disk cleanup"
cleanmgr /sagerun:1 /VeryLowDisk /AUTOCLEAN | Out-Null
Write-Host "dism image cleanup"
dism.exe /Online /Cleanup-Image /RestoreHealth
dism.exe /Online /Cleanup-Image /StartComponentCleanup
dism.exe /Online /Cleanup-Image /SPSuperseded
Restart-Service Themes -Force
stop-process -name explorer -force
Write-Host "Done"