Windows10Debloater.ps1 34 KB

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