Windows10Debloater.ps1 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  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|Framework|`
  32. Microsoft.HEIFImageExtension|Microsoft.ScreenSketch|Microsoft.StorePurchaseApp|Microsoft.VP9VideoExtensions|Microsoft.WebMediaExtensions|Microsoft.WebpImageExtension|Microsoft.DesktopAppInstaller|WindSynthBerry|MIDIBerry|Slack'
  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. "*Windows.CBSPreview*"
  94. #Optional: Typically not removed but you can if you need to for some reason
  95. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*"
  96. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*"
  97. #"*Microsoft.BingWeather*"
  98. #"*Microsoft.MSPaint*"
  99. #"*Microsoft.MicrosoftStickyNotes*"
  100. #"*Microsoft.Windows.Photos*"
  101. #"*Microsoft.WindowsCalculator*"
  102. #"*Microsoft.WindowsStore*"
  103. )
  104. foreach ($Bloat in $Bloatware) {
  105. Get-AppxPackage -Name $Bloat| Remove-AppxPackage -ErrorAction SilentlyContinue
  106. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  107. Write-Output "Trying to remove $Bloat."
  108. }
  109. }
  110. Function Remove-Keys {
  111. [CmdletBinding()]
  112. Param()
  113. #These are the registry keys that it will delete.
  114. $Keys = @(
  115. #Remove Background Tasks
  116. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  117. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  118. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  119. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  120. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  121. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  122. #Windows File
  123. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  124. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  125. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  126. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  127. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  128. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  129. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  130. #Scheduled Tasks to delete
  131. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  132. #Windows Protocol Keys
  133. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  134. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  135. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  136. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  137. #Windows Share Target
  138. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  139. )
  140. #This writes the output of each key it is removing and also removes the keys listed above.
  141. ForEach ($Key in $Keys) {
  142. Write-Output "Removing $Key from registry"
  143. Remove-Item $Key -Recurse
  144. }
  145. }
  146. Function Protect-Privacy {
  147. [CmdletBinding()]
  148. Param()
  149. #Disables Windows Feedback Experience
  150. Write-Output "Disabling Windows Feedback Experience program"
  151. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  152. If (Test-Path $Advertising) {
  153. Set-ItemProperty $Advertising Enabled -Value 0
  154. }
  155. #Stops Cortana from being used as part of your Windows Search Function
  156. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  157. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  158. If (Test-Path $Search) {
  159. Set-ItemProperty $Search AllowCortana -Value 0
  160. }
  161. #Disables Web Search in Start Menu
  162. Write-Output "Disabling Bing Search in Start Menu"
  163. $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  164. Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0
  165. If (!(Test-Path $WebSearch)) {
  166. New-Item $WebSearch
  167. }
  168. Set-ItemProperty $WebSearch DisableWebSearch -Value 1
  169. #Stops the Windows Feedback Experience from sending anonymous data
  170. Write-Output "Stopping the Windows Feedback Experience program"
  171. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  172. If (!(Test-Path $Period)) {
  173. New-Item $Period
  174. }
  175. Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
  176. #Prevents bloatware applications from returning and removes Start Menu suggestions
  177. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  178. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  179. $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  180. If (!(Test-Path $registryPath)) {
  181. New-Item $registryPath
  182. }
  183. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  184. If (!(Test-Path $registryOEM)) {
  185. New-Item $registryOEM
  186. }
  187. Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0
  188. Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0
  189. Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0
  190. Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0
  191. Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0
  192. Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0
  193. #Preping mixed Reality Portal for removal
  194. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  195. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  196. If (Test-Path $Holo) {
  197. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  198. }
  199. #Disables Wi-fi Sense
  200. Write-Output "Disabling Wi-Fi Sense"
  201. $WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
  202. $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
  203. $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
  204. If (!(Test-Path $WifiSense1)) {
  205. New-Item $WifiSense1
  206. }
  207. Set-ItemProperty $WifiSense1 Value -Value 0
  208. If (!(Test-Path $WifiSense2)) {
  209. New-Item $WifiSense2
  210. }
  211. Set-ItemProperty $WifiSense2 Value -Value 0
  212. Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
  213. #Disables live tiles
  214. Write-Output "Disabling live tiles"
  215. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  216. If (!(Test-Path $Live)) {
  217. New-Item $Live
  218. }
  219. Set-ItemProperty $Live NoTileApplicationNotification -Value 1
  220. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  221. Write-Output "Turning off Data Collection"
  222. $DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  223. $DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
  224. $DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  225. If (Test-Path $DataCollection1) {
  226. Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
  227. }
  228. If (Test-Path $DataCollection2) {
  229. Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
  230. }
  231. If (Test-Path $DataCollection3) {
  232. Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
  233. }
  234. #Disabling Location Tracking
  235. Write-Output "Disabling Location Tracking"
  236. $SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
  237. $LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
  238. If (!(Test-Path $SensorState)) {
  239. New-Item $SensorState
  240. }
  241. Set-ItemProperty $SensorState SensorPermissionState -Value 0
  242. If (!(Test-Path $LocationConfig)) {
  243. New-Item $LocationConfig
  244. }
  245. Set-ItemProperty $LocationConfig Status -Value 0
  246. #Disables People icon on Taskbar
  247. Write-Output "Disabling People icon on Taskbar"
  248. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  249. If (Test-Path $People) {
  250. Set-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  251. }
  252. #Disables scheduled tasks that are considered unnecessary
  253. Write-Output "Disabling scheduled tasks"
  254. Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
  255. Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
  256. Get-ScheduledTask Consolidator | Disable-ScheduledTask
  257. Get-ScheduledTask UsbCeip | Disable-ScheduledTask
  258. Get-ScheduledTask DmClient | Disable-ScheduledTask
  259. Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
  260. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  261. #Disabling the Diagnostics Tracking Service
  262. Stop-Service "DiagTrack"
  263. Set-Service "DiagTrack" -StartupType Disabled
  264. Write-Output "Removing CloudStore from registry if it exists"
  265. $CloudStore = 'HKCUSoftware\Microsoft\Windows\CurrentVersion\CloudStore'
  266. If (Test-Path $CloudStore) {
  267. Stop-Process Explorer.exe -Force
  268. Remove-Item $CloudStore
  269. Start-Process Explorer.exe -Wait
  270. }
  271. }
  272. Function DisableCortana {
  273. Write-Host "Disabling Cortana"
  274. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  275. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  276. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  277. If (!(Test-Path $Cortana1)) {
  278. New-Item $Cortana1
  279. }
  280. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  281. If (!(Test-Path $Cortana2)) {
  282. New-Item $Cortana2
  283. }
  284. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  285. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  286. If (!(Test-Path $Cortana3)) {
  287. New-Item $Cortana3
  288. }
  289. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  290. }
  291. Function EnableCortana {
  292. Write-Host "Re-enabling Cortana"
  293. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  294. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  295. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  296. If (!(Test-Path $Cortana1)) {
  297. New-Item $Cortana1
  298. }
  299. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  300. If (!(Test-Path $Cortana2)) {
  301. New-Item $Cortana2
  302. }
  303. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  304. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  305. If (!(Test-Path $Cortana3)) {
  306. New-Item $Cortana3
  307. }
  308. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  309. }
  310. Function Stop-EdgePDF {
  311. #Stops edge from taking over as the default .PDF viewer
  312. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  313. $NoPDF = "HKCR:\.pdf"
  314. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  315. $NoWithList = "HKCR:\.pdf\OpenWithList"
  316. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  317. New-ItemProperty $NoPDF NoOpenWith
  318. }
  319. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  320. New-ItemProperty $NoPDF NoStaticDefaultVerb
  321. }
  322. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  323. New-ItemProperty $NoProgids NoOpenWith
  324. }
  325. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  326. New-ItemProperty $NoProgids NoStaticDefaultVerb
  327. }
  328. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  329. New-ItemProperty $NoWithList NoOpenWith
  330. }
  331. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  332. New-ItemProperty $NoWithList NoStaticDefaultVerb
  333. }
  334. #Appends an underscore '_' to the Registry key for Edge
  335. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  336. If (Test-Path $Edge) {
  337. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  338. }
  339. }
  340. Function Revert-Changes {
  341. [CmdletBinding()]
  342. Param()
  343. #This function will revert the changes you made when running the Start-Debloat function.
  344. #This line reinstalls all of the bloatware that was removed
  345. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  346. #Tells Windows to enable your advertising information.
  347. Write-Output "Re-enabling key to show advertisement information"
  348. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  349. If (Test-Path $Advertising) {
  350. Set-ItemProperty $Advertising Enabled -Value 1
  351. }
  352. #Enables Cortana to be used as part of your Windows Search Function
  353. Write-Output "Re-enabling Cortana to be used in your Windows Search"
  354. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  355. If (Test-Path $Search) {
  356. Set-ItemProperty $Search AllowCortana -Value 1
  357. }
  358. #Re-enables the Windows Feedback Experience for sending anonymous data
  359. Write-Output "Re-enabling Windows Feedback Experience"
  360. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  361. If (!(Test-Path $Period)) {
  362. New-Item $Period
  363. }
  364. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  365. #Enables bloatware applications
  366. Write-Output "Adding Registry key to allow bloatware apps to return"
  367. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  368. If (!(Test-Path $registryPath)) {
  369. New-Item $registryPath
  370. }
  371. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  372. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  373. Write-Output "Setting Mixed Reality Portal value to 1"
  374. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  375. If (Test-Path $Holo) {
  376. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  377. }
  378. #Re-enables live tiles
  379. Write-Output "Enabling live tiles"
  380. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  381. If (!(Test-Path $Live)) {
  382. New-Item $Live
  383. }
  384. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  385. #Re-enables data collection
  386. Write-Output "Re-enabling data collection"
  387. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  388. If (!(Test-Path $DataCollection)) {
  389. New-Item $DataCollection
  390. }
  391. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  392. #Re-enables People Icon on Taskbar
  393. Write-Output "Enabling People icon on Taskbar"
  394. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  395. If (!(Test-Path $People)) {
  396. New-Item $People
  397. }
  398. Set-ItemProperty $People PeopleBand -Value 1
  399. #Re-enables suggestions on start menu
  400. Write-Output "Enabling suggestions on the Start Menu"
  401. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  402. If (!(Test-Path $Suggestions)) {
  403. New-Item $Suggestions
  404. }
  405. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  406. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  407. Write-Output "Enabling scheduled tasks that were disabled"
  408. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  409. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  410. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  411. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  412. Get-ScheduledTask DmClient | Enable-ScheduledTask
  413. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  414. Write-Output "Re-enabling and starting WAP Push Service"
  415. #Enable and start WAP Push Service
  416. Set-Service "dmwappushservice" -StartupType Automatic
  417. Start-Service "dmwappushservice"
  418. Write-Output "Re-enabling and starting the Diagnostics Tracking Service"
  419. #Enabling the Diagnostics Tracking Service
  420. Set-Service "DiagTrack" -StartupType Automatic
  421. Start-Service "DiagTrack"
  422. }
  423. Function CheckDMWService {
  424. Param([switch]$Debloat)
  425. If (Get-Service -Name dmwappushservice | Where-Object {$_.StartType -eq "Disabled"}) {
  426. Set-Service -Name dmwappushservice -StartupType Automatic}
  427. If(Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  428. Start-Service -Name dmwappushservice}
  429. }
  430. Function Enable-EdgePDF {
  431. Write-Output "Setting Edge back to default"
  432. $NoPDF = "HKCR:\.pdf"
  433. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  434. $NoWithList = "HKCR:\.pdf\OpenWithList"
  435. #Sets edge back to default
  436. If (Get-ItemProperty $NoPDF NoOpenWith) {
  437. Remove-ItemProperty $NoPDF NoOpenWith
  438. }
  439. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  440. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  441. }
  442. If (Get-ItemProperty $NoProgids NoOpenWith) {
  443. Remove-ItemProperty $NoProgids NoOpenWith
  444. }
  445. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  446. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  447. }
  448. If (Get-ItemProperty $NoWithList NoOpenWith) {
  449. Remove-ItemProperty $NoWithList NoOpenWith
  450. }
  451. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  452. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  453. }
  454. #Removes an underscore '_' from the Registry key for Edge
  455. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  456. If (Test-Path $Edge2) {
  457. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  458. }
  459. }
  460. Function FixWhitelistedApps {
  461. [CmdletBinding()]
  462. Param()
  463. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  464. #Credit to abulgatz for these 4 lines of code
  465. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  466. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  467. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  468. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  469. }
  470. }
  471. Function UninstallOneDrive {
  472. Write-Output "Checking for pre-existing files and folders located in the OneDrive folders..."
  473. Start-Sleep 1
  474. If (Get-Item -Path "$env:USERPROFILE\OneDrive\*") {
  475. Write-Output "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
  476. Start-Sleep 1
  477. If (Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue) {
  478. Write-Output "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder."
  479. }
  480. else {
  481. If (!(Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue)) {
  482. 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."
  483. New-item -Path "$env:USERPROFILE\Desktop" -Name "OneDriveBackupFiles"-ItemType Directory -Force
  484. Write-Output "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
  485. }
  486. }
  487. Start-Sleep 1
  488. Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
  489. Write-Output "Successfully moved all files/folders from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
  490. Start-Sleep 1
  491. Write-Output "Proceeding with the removal of OneDrive."
  492. Start-Sleep 1
  493. }
  494. Else {
  495. If (!(Get-Item -Path "$env:USERPROFILE\OneDrive\*")) {
  496. 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."
  497. Start-Sleep 1
  498. }
  499. }
  500. Write-Output "Uninstalling OneDrive"
  501. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  502. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  503. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  504. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  505. Stop-Process -Name "OneDrive*"
  506. Start-Sleep 2
  507. If (!(Test-Path $onedrive)) {
  508. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  509. }
  510. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  511. Start-Sleep 2
  512. Write-Output "Stopping explorer"
  513. Start-Sleep 1
  514. .\taskkill.exe /F /IM explorer.exe
  515. Start-Sleep 3
  516. Write-Output "Removing leftover files"
  517. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  518. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  519. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  520. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  521. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  522. }
  523. Write-Output "Removing OneDrive from windows explorer"
  524. If (!(Test-Path $ExplorerReg1)) {
  525. New-Item $ExplorerReg1
  526. }
  527. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  528. If (!(Test-Path $ExplorerReg2)) {
  529. New-Item $ExplorerReg2
  530. }
  531. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  532. Write-Output "Restarting Explorer that was shut down before."
  533. Start-Process explorer.exe -NoNewWindow
  534. Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
  535. $OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  536. If (!(Test-Path $OneDriveKey)) {
  537. Mkdir $OneDriveKey
  538. }
  539. $DisableAllOneDrive = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  540. If (Test-Path $DisableAllOneDrive) {
  541. New-ItemProperty $DisableAllOneDrive -Name OneDrive -Value DisableFileSyncNGSC -Verbose
  542. }
  543. }
  544. Function UnpinStart {
  545. #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
  546. #Unpins all tiles from the Start Menu
  547. Write-Output "Unpinning all tiles from the start menu"
  548. (New-Object -Com Shell.Application).
  549. NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
  550. Items() |
  551. %{ $_.Verbs() } |
  552. ?{$_.Name -match 'Un.*pin from Start'} |
  553. %{$_.DoIt()}
  554. }
  555. #GUI prompt Debloat/Revert options and GUI variables
  556. $Button = [Windows.MessageBoxButton]::YesNoCancel
  557. $ErrorIco = [Windows.MessageBoxImage]::Error
  558. $Warn = [Windows.MessageBoxImage]::Warning
  559. $Ask = 'The following will allow you to either Debloat Windows 10 or to revert changes made after Debloating Windows 10.
  560. Select "Yes" to Debloat Windows 10
  561. Select "No" to Revert changes made by this script
  562. Select "Cancel" to stop the script.'
  563. $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."
  564. $EdgePdf = "Do you want to stop edge from taking over as the default PDF viewer?"
  565. $EdgePdf2 = "Do you want to revert changes that disabled Edge as the default PDF viewer?"
  566. $Reboot = "For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
  567. $OneDriveDelete = "Do you want to uninstall One Drive?"
  568. $Unpin = "Do you want to unpin all items from the Start menu?"
  569. $InstallNET = "Do you want to install .NET 3.5?"
  570. $Prompt1 = [Windows.MessageBox]::Show($Ask, "Debloat or Revert", $Button, $ErrorIco)
  571. Switch ($Prompt1) {
  572. #This will debloat Windows 10
  573. Yes {
  574. $Prompt2 = [Windows.MessageBox]::Show($EverythingorSpecific, "Everything or Specific", $Button, $Warn)
  575. switch ($Prompt2) {
  576. Yes {
  577. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  578. 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."
  579. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  580. Start-Sleep 1
  581. Write-Output "Uninstalling bloatware, please wait."
  582. DebloatAll
  583. Write-Output "Bloatware removed."
  584. Start-Sleep 1
  585. Write-Output "Removing specific registry keys."
  586. Remove-Keys
  587. Write-Output "Leftover bloatware registry keys removed."
  588. Start-Sleep 1
  589. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  590. Start-Sleep 1
  591. FixWhitelistedApps
  592. Start-Sleep 1
  593. Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  594. Protect-Privacy
  595. Start-Sleep 1
  596. DisableCortana
  597. Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  598. Start-Sleep 1
  599. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  600. DisableDiagTrack
  601. Write-Output "Diagnostics Tracking Service disabled"
  602. Start-Sleep 1
  603. Write-Output "Disabling WAP push service"
  604. Start-Sleep 1
  605. DisableWAPPush
  606. Write-Output "Re-enabling DMWAppushservice if it was disabled"
  607. CheckDMWService
  608. Start-Sleep 1
  609. }
  610. No {
  611. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  612. 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."
  613. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  614. Start-Sleep 1
  615. Write-Output "Uninstalling bloatware, please wait."
  616. DebloatBlacklist
  617. Write-Output "Bloatware removed."
  618. Start-Sleep 1
  619. Write-Output "Removing specific registry keys."
  620. Remove-Keys
  621. Write-Output "Leftover bloatware registry keys removed."
  622. Start-Sleep 1
  623. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  624. Start-Sleep 1
  625. FixWhitelistedApps
  626. Start-Sleep 1
  627. Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  628. Protect-Privacy
  629. Start-Sleep 1
  630. DisableCortana
  631. Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  632. Start-Sleep 1
  633. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  634. DisableDiagTrack
  635. Write-Output "Diagnostics Tracking Service disabled"
  636. Start-Sleep 1
  637. Write-Output "Disabling WAP push service"
  638. Start-Sleep 1
  639. DisableWAPPush
  640. Write-Output "Re-enabling DMWAppushservice if it was disabled"
  641. CheckDMWService
  642. Start-Sleep 1
  643. }
  644. }
  645. $Prompt3 = [Windows.MessageBox]::Show($EdgePdf, "Edge PDF", $Button, $Warn)
  646. Switch ($Prompt3) {
  647. Yes {
  648. Stop-EdgePDF
  649. Write-Output "Edge will no longer take over as the default PDF viewer."
  650. }
  651. No {
  652. Write-Output "You chose not to stop Edge from taking over as the default PDF viewer."
  653. }
  654. }
  655. #Prompt asking to delete OneDrive
  656. $Prompt4 = [Windows.MessageBox]::Show($OneDriveDelete, "Delete OneDrive", $Button, $ErrorIco)
  657. Switch ($Prompt4) {
  658. Yes {
  659. UninstallOneDrive
  660. Write-Output "OneDrive is now removed from the computer."
  661. }
  662. No {
  663. Write-Output "You have chosen to skip removing OneDrive from your machine."
  664. }
  665. }
  666. #Prompt asking if you'd like to unpin all start items
  667. $Prompt5 = [Windows.MessageBox]::Show($Unpin, "Unpin", $Button, $ErrorIco)
  668. Switch ($Prompt5) {
  669. Yes {
  670. UnpinStart
  671. Write-Output "Start Apps unpined."
  672. }
  673. No {
  674. Write-Output "You have chosen to skip removing OneDrive from your machine."
  675. }
  676. }
  677. $Prompt6 = [Windows.MessageBox]::Show($InstallNET, "Install .Net", $Button, $Warn)
  678. Switch ($Prompt6) {
  679. Yes {
  680. Write-Output "Initializing the installation of .NET 3.5..."
  681. Try {
  682. DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
  683. Write-Output ".NET 3.5 has been successfully installed!" }
  684. Catch {
  685. $_
  686. }
  687. }
  688. }
  689. #Prompt asking if you'd like to reboot your machine
  690. $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
  691. Switch ($Prompt7) {
  692. Yes {
  693. Write-Output "Unloading the HKCR drive..."
  694. Remove-PSDrive HKCR
  695. Start-Sleep 1
  696. Stop-Transcript
  697. Write-Output "Initiating reboot."
  698. Start-Sleep 2
  699. Restart-Computer
  700. }
  701. No {
  702. Write-Output "Unloading the HKCR drive..."
  703. Remove-PSDrive HKCR
  704. Start-Sleep 1
  705. Stop-Transcript
  706. Write-Output "Script has finished. Exiting."
  707. Start-Sleep 2
  708. Exit
  709. }
  710. }
  711. }
  712. No {
  713. Write-Output "Reverting changes..."
  714. 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."
  715. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  716. Revert-Changes
  717. #Prompt asking to revert edge changes as well
  718. $Prompt6 = [Windows.MessageBox]::Show($EdgePdf2, "Revert Edge", $Button, $ErrorIco)
  719. Switch ($Prompt6) {
  720. Yes {
  721. Enable-EdgePDF
  722. Write-Output "Edge will no longer be disabled from being used as the default Edge PDF viewer."
  723. }
  724. No {
  725. Write-Output "You have chosen to keep the setting that disallows Edge to be the default PDF viewer."
  726. }
  727. }
  728. #Prompt asking if you'd like to reboot your machine
  729. $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
  730. Switch ($Prompt7) {
  731. Yes {
  732. Write-Output "Unloading the HKCR drive..."
  733. Remove-PSDrive HKCR
  734. Start-Sleep 1
  735. Write-Output "Initiating reboot."
  736. Stop-Transcript
  737. Start-Sleep 2
  738. Restart-Computer
  739. }
  740. No {
  741. Write-Output "Unloading the HKCR drive..."
  742. Remove-PSDrive HKCR
  743. Start-Sleep 1
  744. Write-Output "Script has finished. Exiting."
  745. Stop-Transcript
  746. Start-Sleep 2
  747. Exit
  748. }
  749. }
  750. }
  751. }