Windows10Debloater.ps1 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  2. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  3. #This will self elevate the script so with a UAC prompt since this script needs to be run as an Administrator in order to function properly.
  4. If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
  5. $arguments = "&" + $MyInvocation.MyCommand.Definition + ""
  6. Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator." -ForegroundColor "White"
  7. Start-Sleep 1
  8. Start-Process "powershell.exe" -Verb RunAs -ArgumentList $arguments
  9. Break
  10. }
  11. #no errors throughout
  12. $ErrorActionPreference = 'silentlycontinue'
  13. $DebloatFolder = "C:\Temp\Windows10Debloater"
  14. If (Test-Path $DebloatFolder) {
  15. Write-Output "$DebloatFolder exists. Skipping."
  16. }
  17. Else {
  18. Write-Output "The folder "$DebloatFolder" doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
  19. Start-Sleep 1
  20. New-Item -Path "$DebloatFolder" -ItemType Directory
  21. Write-Output "The folder $DebloatFolder was successfully created."
  22. }
  23. Start-Transcript -OutputDirectory "$DebloatFolder"
  24. Add-Type -AssemblyName PresentationCore, PresentationFramework
  25. Function DebloatAll {
  26. [CmdletBinding()]
  27. Param()
  28. #Removes AppxPackages
  29. #Credit to /u/GavinEke for a modified version of my whitelist code
  30. [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|`
  31. Microsoft.XboxGameCallableUI|Microsoft.XboxGamingOverlay|Microsoft.Xbox.TCUI|Microsoft.XboxGamingOverlay|Microsoft.XboxIdentityProvider|Microsoft.MicrosoftStickyNotes|Microsoft.MSPaint|Microsoft.WindowsCamera|.NET|`
  32. Microsoft.HEIFImageExtension|Microsoft.ScreenSketch|Microsoft.StorePurchaseApp|Microsoft.VP9VideoExtensions|Microsoft.WebMediaExtensions|Microsoft.WebpImageExtension|Microsoft.DesktopAppInstaller|WindSynthBerry|MIDIBerry'
  33. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
  34. Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
  35. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online
  36. }
  37. Function DebloatBlacklist {
  38. [CmdletBinding()]
  39. Param ()
  40. $Bloatware = @(
  41. #Unnecessary Windows 10 AppX Apps
  42. "Microsoft.BingNews"
  43. "Microsoft.GetHelp"
  44. "Microsoft.Getstarted"
  45. "Microsoft.Messaging"
  46. "Microsoft.Microsoft3DViewer"
  47. "Microsoft.MicrosoftOfficeHub"
  48. "Microsoft.MicrosoftSolitaireCollection"
  49. "Microsoft.NetworkSpeedTest"
  50. "Microsoft.News"
  51. "Microsoft.Office.Lens"
  52. "Microsoft.Office.OneNote"
  53. "Microsoft.Office.Sway"
  54. "Microsoft.OneConnect"
  55. "Microsoft.People"
  56. "Microsoft.Print3D"
  57. "Microsoft.RemoteDesktop"
  58. "Microsoft.SkypeApp"
  59. "Microsoft.StorePurchaseApp"
  60. "Microsoft.Office.Todo.List"
  61. "Microsoft.Whiteboard"
  62. "Microsoft.WindowsAlarms"
  63. #"Microsoft.WindowsCamera"
  64. "microsoft.windowscommunicationsapps"
  65. "Microsoft.WindowsFeedbackHub"
  66. "Microsoft.WindowsMaps"
  67. "Microsoft.WindowsSoundRecorder"
  68. "Microsoft.Xbox.TCUI"
  69. "Microsoft.XboxApp"
  70. "Microsoft.XboxGameOverlay"
  71. "Microsoft.XboxIdentityProvider"
  72. "Microsoft.XboxSpeechToTextOverlay"
  73. "Microsoft.ZuneMusic"
  74. "Microsoft.ZuneVideo"
  75. #Sponsored Windows 10 AppX Apps
  76. #Add sponsored/featured apps to remove in the "*AppName*" format
  77. "*EclipseManager*"
  78. "*ActiproSoftwareLLC*"
  79. "*AdobeSystemsIncorporated.AdobePhotoshopExpress*"
  80. "*Duolingo-LearnLanguagesforFree*"
  81. "*PandoraMediaInc*"
  82. "*CandyCrush*"
  83. "*Wunderlist*"
  84. "*Flipboard*"
  85. "*Twitter*"
  86. "*Facebook*"
  87. "*Spotify*"
  88. "*Minecraft*"
  89. "*Royal Revolt*"
  90. "*Sway*"
  91. "*Speed Test*"
  92. "*Dolby*"
  93. #Optional: Typically not removed but you can if you need to for some reason
  94. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*"
  95. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*"
  96. #"*Microsoft.BingWeather*"
  97. #"*Microsoft.MSPaint*"
  98. #"*Microsoft.MicrosoftStickyNotes*"
  99. #"*Microsoft.Windows.Photos*"
  100. #"*Microsoft.WindowsCalculator*"
  101. #"*Microsoft.WindowsStore*"
  102. )
  103. foreach ($Bloat in $Bloatware) {
  104. Get-AppxPackage -Name $Bloat| Remove-AppxPackage -ErrorAction SilentlyContinue
  105. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Debloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  106. Write-Output "Trying to remove $Bloat."
  107. }
  108. }
  109. Function Remove-Keys {
  110. [CmdletBinding()]
  111. Param()
  112. #These are the registry keys that it will delete.
  113. $Keys = @(
  114. #Remove Background Tasks
  115. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  116. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  117. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  118. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  119. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  120. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  121. #Windows File
  122. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  123. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  124. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  125. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  126. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  127. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  128. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  129. #Scheduled Tasks to delete
  130. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  131. #Windows Protocol Keys
  132. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  133. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  134. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  135. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  136. #Windows Share Target
  137. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  138. )
  139. #This writes the output of each key it is removing and also removes the keys listed above.
  140. ForEach ($Key in $Keys) {
  141. Write-Output "Removing $Key from registry"
  142. Remove-Item $Key -Recurse
  143. }
  144. }
  145. Function Protect-Privacy {
  146. [CmdletBinding()]
  147. Param()
  148. #Disables Windows Feedback Experience
  149. Write-Output "Disabling Windows Feedback Experience program"
  150. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  151. If (Test-Path $Advertising) {
  152. Set-ItemProperty $Advertising Enabled -Value 0
  153. }
  154. #Stops Cortana from being used as part of your Windows Search Function
  155. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  156. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  157. If (Test-Path $Search) {
  158. Set-ItemProperty $Search AllowCortana -Value 0
  159. }
  160. #Disables Web Search in Start Menu
  161. Write-Output "Disabling Bing Search in Start Menu"
  162. $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  163. Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0
  164. If (!(Test-Path $WebSearch)) {
  165. New-Item $WebSearch
  166. }
  167. Set-ItemProperty $WebSearch DisableWebSearch -Value 1
  168. #Stops the Windows Feedback Experience from sending anonymous data
  169. Write-Output "Stopping the Windows Feedback Experience program"
  170. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  171. If (!(Test-Path $Period)) {
  172. New-Item $Period
  173. }
  174. Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
  175. #Prevents bloatware applications from returning and removes Start Menu suggestions
  176. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  177. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  178. $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  179. If (!(Test-Path $registryPath)) {
  180. New-Item $registryPath
  181. }
  182. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  183. If (!(Test-Path $registryOEM)) {
  184. New-Item $registryOEM
  185. }
  186. Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0
  187. Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0
  188. Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0
  189. Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0
  190. Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0
  191. Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0
  192. #Preping mixed Reality Portal for removal
  193. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  194. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  195. If (Test-Path $Holo) {
  196. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  197. }
  198. #Disables Wi-fi Sense
  199. Write-Output "Disabling Wi-Fi Sense"
  200. $WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
  201. $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
  202. $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
  203. If (!(Test-Path $WifiSense1)) {
  204. New-Item $WifiSense1
  205. }
  206. Set-ItemProperty $WifiSense1 Value -Value 0
  207. If (!(Test-Path $WifiSense2)) {
  208. New-Item $WifiSense2
  209. }
  210. Set-ItemProperty $WifiSense2 Value -Value 0
  211. Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
  212. #Disables live tiles
  213. Write-Output "Disabling live tiles"
  214. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  215. If (!(Test-Path $Live)) {
  216. New-Item $Live
  217. }
  218. Set-ItemProperty $Live NoTileApplicationNotification -Value 1
  219. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  220. Write-Output "Turning off Data Collection"
  221. $DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  222. $DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
  223. $DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  224. If (Test-Path $DataCollection1) {
  225. Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
  226. }
  227. If (Test-Path $DataCollection2) {
  228. Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
  229. }
  230. If (Test-Path $DataCollection3) {
  231. Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
  232. }
  233. #Disabling Location Tracking
  234. Write-Output "Disabling Location Tracking"
  235. $SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
  236. $LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
  237. If (!(Test-Path $SensorState)) {
  238. New-Item $SensorState
  239. }
  240. Set-ItemProperty $SensorState SensorPermissionState -Value 0
  241. If (!(Test-Path $LocationConfig)) {
  242. New-Item $LocationConfig
  243. }
  244. Set-ItemProperty $LocationConfig Status -Value 0
  245. #Disables People icon on Taskbar
  246. Write-Output "Disabling People icon on Taskbar"
  247. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  248. If (Test-Path $People) {
  249. Set-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  250. }
  251. #Disables scheduled tasks that are considered unnecessary
  252. Write-Output "Disabling scheduled tasks"
  253. Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
  254. Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
  255. Get-ScheduledTask Consolidator | Disable-ScheduledTask
  256. Get-ScheduledTask UsbCeip | Disable-ScheduledTask
  257. Get-ScheduledTask DmClient | Disable-ScheduledTask
  258. Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
  259. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  260. #Disabling the Diagnostics Tracking Service
  261. Stop-Service "DiagTrack"
  262. Set-Service "DiagTrack" -StartupType Disabled
  263. Write-Output "Removing CloudStore from registry if it exists"
  264. $CloudStore = 'HKCUSoftware\Microsoft\Windows\CurrentVersion\CloudStore'
  265. If (Test-Path $CloudStore) {
  266. Stop-Process Explorer.exe -Force
  267. Remove-Item $CloudStore
  268. Start-Process Explorer.exe -Wait
  269. }
  270. }
  271. Function DisableCortana {
  272. Write-Host "Disabling Cortana"
  273. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  274. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  275. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  276. If (!(Test-Path $Cortana1)) {
  277. New-Item $Cortana1
  278. }
  279. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  280. If (!(Test-Path $Cortana2)) {
  281. New-Item $Cortana2
  282. }
  283. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  284. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  285. If (!(Test-Path $Cortana3)) {
  286. New-Item $Cortana3
  287. }
  288. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  289. }
  290. Function EnableCortana {
  291. Write-Host "Re-enabling Cortana"
  292. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  293. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  294. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  295. If (!(Test-Path $Cortana1)) {
  296. New-Item $Cortana1
  297. }
  298. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  299. If (!(Test-Path $Cortana2)) {
  300. New-Item $Cortana2
  301. }
  302. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  303. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  304. If (!(Test-Path $Cortana3)) {
  305. New-Item $Cortana3
  306. }
  307. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  308. }
  309. Function Stop-EdgePDF {
  310. #Stops edge from taking over as the default .PDF viewer
  311. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  312. $NoPDF = "HKCR:\.pdf"
  313. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  314. $NoWithList = "HKCR:\.pdf\OpenWithList"
  315. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  316. New-ItemProperty $NoPDF NoOpenWith
  317. }
  318. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  319. New-ItemProperty $NoPDF NoStaticDefaultVerb
  320. }
  321. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  322. New-ItemProperty $NoProgids NoOpenWith
  323. }
  324. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  325. New-ItemProperty $NoProgids NoStaticDefaultVerb
  326. }
  327. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  328. New-ItemProperty $NoWithList NoOpenWith
  329. }
  330. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  331. New-ItemProperty $NoWithList NoStaticDefaultVerb
  332. }
  333. #Appends an underscore '_' to the Registry key for Edge
  334. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  335. If (Test-Path $Edge) {
  336. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  337. }
  338. }
  339. Function Revert-Changes {
  340. [CmdletBinding()]
  341. Param()
  342. #This function will revert the changes you made when running the Start-Debloat function.
  343. #This line reinstalls all of the bloatware that was removed
  344. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  345. #Tells Windows to enable your advertising information.
  346. Write-Output "Re-enabling key to show advertisement information"
  347. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  348. If (Test-Path $Advertising) {
  349. Set-ItemProperty $Advertising Enabled -Value 1
  350. }
  351. #Enables Cortana to be used as part of your Windows Search Function
  352. Write-Output "Re-enabling Cortana to be used in your Windows Search"
  353. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  354. If (Test-Path $Search) {
  355. Set-ItemProperty $Search AllowCortana -Value 1
  356. }
  357. #Re-enables the Windows Feedback Experience for sending anonymous data
  358. Write-Output "Re-enabling Windows Feedback Experience"
  359. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  360. If (!(Test-Path $Period)) {
  361. New-Item $Period
  362. }
  363. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  364. #Enables bloatware applications
  365. Write-Output "Adding Registry key to allow bloatware apps to return"
  366. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  367. If (!(Test-Path $registryPath)) {
  368. New-Item $registryPath
  369. }
  370. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  371. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  372. Write-Output "Setting Mixed Reality Portal value to 1"
  373. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  374. If (Test-Path $Holo) {
  375. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  376. }
  377. #Re-enables live tiles
  378. Write-Output "Enabling live tiles"
  379. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  380. If (!(Test-Path $Live)) {
  381. New-Item $Live
  382. }
  383. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  384. #Re-enables data collection
  385. Write-Output "Re-enabling data collection"
  386. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  387. If (!(Test-Path $DataCollection)) {
  388. New-Item $DataCollection
  389. }
  390. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  391. #Re-enables People Icon on Taskbar
  392. Write-Output "Enabling People icon on Taskbar"
  393. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  394. If (!(Test-Path $People)) {
  395. New-Item $People
  396. }
  397. Set-ItemProperty $People PeopleBand -Value 1
  398. #Re-enables suggestions on start menu
  399. Write-Output "Enabling suggestions on the Start Menu"
  400. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  401. If (!(Test-Path $Suggestions)) {
  402. New-Item $Suggestions
  403. }
  404. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  405. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  406. Write-Output "Enabling scheduled tasks that were disabled"
  407. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  408. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  409. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  410. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  411. Get-ScheduledTask DmClient | Enable-ScheduledTask
  412. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  413. Write-Output "Re-enabling and starting WAP Push Service"
  414. #Enable and start WAP Push Service
  415. Set-Service "dmwappushservice" -StartupType Automatic
  416. Start-Service "dmwappushservice"
  417. Write-Output "Re-enabling and starting the Diagnostics Tracking Service"
  418. #Enabling the Diagnostics Tracking Service
  419. Set-Service "DiagTrack" -StartupType Automatic
  420. Start-Service "DiagTrack"
  421. }
  422. Function CheckDMWService {
  423. Param([switch]$Debloat)
  424. If (Get-Service -Name dmwappushservice | Where-Object {$_.StartType -eq "Disabled"}) {
  425. Set-Service -Name dmwappushservice -StartupType Automatic}
  426. If(Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  427. Start-Service -Name dmwappushservice}
  428. }
  429. Function Enable-EdgePDF {
  430. Write-Output "Setting Edge back to default"
  431. $NoPDF = "HKCR:\.pdf"
  432. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  433. $NoWithList = "HKCR:\.pdf\OpenWithList"
  434. #Sets edge back to default
  435. If (Get-ItemProperty $NoPDF NoOpenWith) {
  436. Remove-ItemProperty $NoPDF NoOpenWith
  437. }
  438. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  439. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  440. }
  441. If (Get-ItemProperty $NoProgids NoOpenWith) {
  442. Remove-ItemProperty $NoProgids NoOpenWith
  443. }
  444. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  445. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  446. }
  447. If (Get-ItemProperty $NoWithList NoOpenWith) {
  448. Remove-ItemProperty $NoWithList NoOpenWith
  449. }
  450. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  451. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  452. }
  453. #Removes an underscore '_' from the Registry key for Edge
  454. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  455. If (Test-Path $Edge2) {
  456. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  457. }
  458. }
  459. Function FixWhitelistedApps {
  460. [CmdletBinding()]
  461. Param()
  462. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  463. #Credit to abulgatz for these 4 lines of code
  464. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  465. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  466. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  467. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  468. }
  469. }
  470. Function UninstallOneDrive {
  471. Write-Output "Checking for pre-existing files and folders located in the OneDrive folders..."
  472. Start-Sleep 1
  473. If (Get-Item -Path "$env:USERPROFILE\OneDrive\*") {
  474. Write-Output "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
  475. Start-Sleep 1
  476. If (Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue) {
  477. Write-Output "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder."
  478. }
  479. else {
  480. If (!(Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue)) {
  481. Write-Output "A folder named OneDriveBackupFiles will be created and will be located on your desktop. All files from your OneDrive location will be located in that folder."
  482. New-item -Path "$env:USERPROFILE\Desktop" -Name "OneDriveBackupFiles"-ItemType Directory -Force
  483. Write-Output "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
  484. }
  485. }
  486. Start-Sleep 1
  487. Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
  488. Write-Output "Successfully moved all files/folders from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
  489. Start-Sleep 1
  490. Write-Output "Proceeding with the removal of OneDrive."
  491. Start-Sleep 1
  492. }
  493. Else {
  494. If (!(Get-Item -Path "$env:USERPROFILE\OneDrive\*")) {
  495. Write-Output "Either the OneDrive folder does not exist or there are no files to be found in the folder. Proceeding with removal of OneDrive."
  496. Start-Sleep 1
  497. }
  498. }
  499. Write-Output "Uninstalling OneDrive"
  500. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  501. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  502. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  503. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  504. Stop-Process -Name "OneDrive*"
  505. Start-Sleep 2
  506. If (!(Test-Path $onedrive)) {
  507. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  508. }
  509. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  510. Start-Sleep 2
  511. Write-Output "Stopping explorer"
  512. Start-Sleep 1
  513. .\taskkill.exe /F /IM explorer.exe
  514. Start-Sleep 3
  515. Write-Output "Removing leftover files"
  516. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  517. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  518. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  519. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  520. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  521. }
  522. Write-Output "Removing OneDrive from windows explorer"
  523. If (!(Test-Path $ExplorerReg1)) {
  524. New-Item $ExplorerReg1
  525. }
  526. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  527. If (!(Test-Path $ExplorerReg2)) {
  528. New-Item $ExplorerReg2
  529. }
  530. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  531. Write-Output "Restarting Explorer that was shut down before."
  532. Start-Process explorer.exe -NoNewWindow
  533. Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
  534. $OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  535. If (!(Test-Path $OneDriveKey)) {
  536. Mkdir $OneDriveKey
  537. }
  538. $DisableAllOneDrive = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  539. If (Test-Path $DisableAllOneDrive) {
  540. New-ItemProperty $DisableAllOneDrive -Name OneDrive -Value DisableFileSyncNGSC -Verbose
  541. }
  542. }
  543. #GUI prompt Debloat/Revert options and GUI variables
  544. $Button = [Windows.MessageBoxButton]::YesNoCancel
  545. $ErrorIco = [Windows.MessageBoxImage]::Error
  546. $Warn = [Windows.MessageBoxImage]::Warning
  547. $Ask = 'The following will allow you to either Debloat Windows 10 or to revert changes made after Debloating Windows 10.
  548. Select "Yes" to Debloat Windows 10
  549. Select "No" to Revert changes made by this script
  550. Select "Cancel" to stop the script.'
  551. $EverythingorSpecific = "Would you like to remove everything that was preinstalled on your Windows Machine? Select Yes to remove everything, or select No to remove apps via a blacklist."
  552. $EdgePdf = "Do you want to stop edge from taking over as the default PDF viewer?"
  553. $EdgePdf2 = "Do you want to revert changes that disabled Edge as the default PDF viewer?"
  554. $Reboot = "For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
  555. $OneDriveDelete = "Do you want to uninstall One Drive?"
  556. $Prompt1 = [Windows.MessageBox]::Show($Ask, "Debloat or Revert", $Button, $ErrorIco)
  557. Switch ($Prompt1) {
  558. #This will debloat Windows 10
  559. Yes {
  560. $Prompt2 = [Windows.MessageBox]::Show($EverythingorSpecific, "Everything or Specific", $Button, $Warn)
  561. switch ($Prompt2) {
  562. Yes {
  563. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  564. Write-Output "Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the removal and modification of specific registry keys."
  565. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  566. Start-Sleep 1
  567. Write-Output "Uninstalling bloatware, please wait."
  568. DebloatAll
  569. Write-Output "Bloatware removed."
  570. Start-Sleep 1
  571. Write-Output "Removing specific registry keys."
  572. Remove-Keys
  573. Write-Output "Leftover bloatware registry keys removed."
  574. Start-Sleep 1
  575. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  576. Start-Sleep 1
  577. FixWhitelistedApps
  578. Start-Sleep 1
  579. Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  580. Protect-Privacy
  581. Start-Sleep 1
  582. DisableCortana
  583. Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  584. Start-Sleep 1
  585. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  586. DisableDiagTrack
  587. Write-Output "Diagnostics Tracking Service disabled"
  588. Start-Sleep 1
  589. Write-Output "Disabling WAP push service"
  590. Start-Sleep 1
  591. DisableWAPPush
  592. Write-Output "Re-enabling DMWAppushservice if it was disabled"
  593. CheckDMWService
  594. Start-Sleep 1
  595. }
  596. No {
  597. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  598. Write-Output "Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the removal and modification of specific registry keys."
  599. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  600. Start-Sleep 1
  601. Write-Output "Uninstalling bloatware, please wait."
  602. DebloatBlacklist
  603. Write-Output "Bloatware removed."
  604. Start-Sleep 1
  605. Write-Output "Removing specific registry keys."
  606. Remove-Keys
  607. Write-Output "Leftover bloatware registry keys removed."
  608. Start-Sleep 1
  609. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  610. Start-Sleep 1
  611. FixWhitelistedApps
  612. Start-Sleep 1
  613. Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  614. Protect-Privacy
  615. Start-Sleep 1
  616. DisableCortana
  617. Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  618. Start-Sleep 1
  619. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  620. DisableDiagTrack
  621. Write-Output "Diagnostics Tracking Service disabled"
  622. Start-Sleep 1
  623. Write-Output "Disabling WAP push service"
  624. Start-Sleep 1
  625. DisableWAPPush
  626. Write-Output "Re-enabling DMWAppushservice if it was disabled"
  627. CheckDMWService
  628. Start-Sleep 1
  629. }
  630. }
  631. $Prompt3 = [Windows.MessageBox]::Show($EdgePdf, "Edge PDF", $Button, $Warn)
  632. Switch ($Prompt3) {
  633. Yes {
  634. Stop-EdgePDF
  635. Write-Output "Edge will no longer take over as the default PDF viewer."
  636. }
  637. No {
  638. Write-Output "You chose not to stop Edge from taking over as the default PDF viewer."
  639. }
  640. }
  641. #Prompt asking to delete OneDrive
  642. $Prompt4 = [Windows.MessageBox]::Show($OneDriveDelete, "Delete OneDrive", $Button, $ErrorIco)
  643. Switch ($Prompt4) {
  644. Yes {
  645. UninstallOneDrive
  646. Write-Output "OneDrive is now removed from the computer."
  647. }
  648. No {
  649. Write-Output "You have chosen to skip removing OneDrive from your machine."
  650. }
  651. }
  652. #Prompt asking if you'd like to reboot your machine
  653. $Prompt5 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
  654. Switch ($Prompt5) {
  655. Yes {
  656. Write-Output "Unloading the HKCR drive..."
  657. Remove-PSDrive HKCR
  658. Start-Sleep 1
  659. Stop-Transcript
  660. Write-Output "Initiating reboot."
  661. Start-Sleep 2
  662. Restart-Computer
  663. }
  664. No {
  665. Write-Output "Unloading the HKCR drive..."
  666. Remove-PSDrive HKCR
  667. Start-Sleep 1
  668. Stop-Transcript
  669. Write-Output "Script has finished. Exiting."
  670. Start-Sleep 2
  671. Exit
  672. }
  673. }
  674. }
  675. No {
  676. Write-Output "Reverting changes..."
  677. Write-Output "Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the modification of specific registry keys."
  678. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  679. Revert-Changes
  680. #Prompt asking to revert edge changes as well
  681. $Prompt6 = [Windows.MessageBox]::Show($EdgePdf2, "Revert Edge", $Button, $ErrorIco)
  682. Switch ($Prompt6) {
  683. Yes {
  684. Enable-EdgePDF
  685. Write-Output "Edge will no longer be disabled from being used as the default Edge PDF viewer."
  686. }
  687. No {
  688. Write-Output "You have chosen to keep the setting that disallows Edge to be the default PDF viewer."
  689. }
  690. }
  691. #Prompt asking if you'd like to reboot your machine
  692. $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
  693. Switch ($Prompt7) {
  694. Yes {
  695. Write-Output "Unloading the HKCR drive..."
  696. Remove-PSDrive HKCR
  697. Start-Sleep 1
  698. Write-Output "Initiating reboot."
  699. Stop-Transcript
  700. Start-Sleep 2
  701. Restart-Computer
  702. }
  703. No {
  704. Write-Output "Unloading the HKCR drive..."
  705. Remove-PSDrive HKCR
  706. Start-Sleep 1
  707. Write-Output "Script has finished. Exiting."
  708. Stop-Transcript
  709. Start-Sleep 2
  710. Exit
  711. }
  712. }
  713. }
  714. }