Windows10Debloater.ps1 30 KB

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