Windows10Debloater.ps1 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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. Write-Output "Stopping and disabling WAP Push Service"
  234. #Stop and disable WAP Push Service
  235. Stop-Service "dmwappushservice"
  236. Set-Service "dmwappushservice" -StartupType Disabled
  237. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  238. #Disabling the Diagnostics Tracking Service
  239. Stop-Service "DiagTrack"
  240. Set-Service "DiagTrack" -StartupType Disabled
  241. }
  242. Function DisableCortana {
  243. Write-Host "Disabling Cortana"
  244. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  245. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  246. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  247. If (!(Test-Path $Cortana1)) {
  248. New-Item $Cortana1
  249. }
  250. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  251. If (!(Test-Path $Cortana2)) {
  252. New-Item $Cortana2
  253. }
  254. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  255. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  256. If (!(Test-Path $Cortana3)) {
  257. New-Item $Cortana3
  258. }
  259. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  260. }
  261. Function EnableCortana {
  262. Write-Host "Re-enabling Cortana"
  263. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  264. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  265. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  266. If (!(Test-Path $Cortana1)) {
  267. New-Item $Cortana1
  268. }
  269. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  270. If (!(Test-Path $Cortana2)) {
  271. New-Item $Cortana2
  272. }
  273. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  274. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  275. If (!(Test-Path $Cortana3)) {
  276. New-Item $Cortana3
  277. }
  278. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  279. }
  280. Function Stop-EdgePDF {
  281. #Stops edge from taking over as the default .PDF viewer
  282. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  283. $NoPDF = "HKCR:\.pdf"
  284. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  285. $NoWithList = "HKCR:\.pdf\OpenWithList"
  286. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  287. New-ItemProperty $NoPDF NoOpenWith
  288. }
  289. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  290. New-ItemProperty $NoPDF NoStaticDefaultVerb
  291. }
  292. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  293. New-ItemProperty $NoProgids NoOpenWith
  294. }
  295. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  296. New-ItemProperty $NoProgids NoStaticDefaultVerb
  297. }
  298. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  299. New-ItemProperty $NoWithList NoOpenWith
  300. }
  301. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  302. New-ItemProperty $NoWithList NoStaticDefaultVerb
  303. }
  304. #Appends an underscore '_' to the Registry key for Edge
  305. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  306. If (Test-Path $Edge) {
  307. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  308. }
  309. }
  310. Function Revert-Changes {
  311. [CmdletBinding()]
  312. Param()
  313. #This function will revert the changes you made when running the Start-Debloat function.
  314. #This line reinstalls all of the bloatware that was removed
  315. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  316. #Tells Windows to enable your advertising information.
  317. Write-Output "Re-enabling key to show advertisement information"
  318. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  319. If (Test-Path $Advertising) {
  320. Set-ItemProperty $Advertising Enabled -Value 1
  321. }
  322. #Enables Cortana to be used as part of your Windows Search Function
  323. Write-Output "Re-enabling Cortana to be used in your Windows Search"
  324. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  325. If (Test-Path $Search) {
  326. Set-ItemProperty $Search AllowCortana -Value 1
  327. }
  328. #Re-enables the Windows Feedback Experience for sending anonymous data
  329. Write-Output "Re-enabling Windows Feedback Experience"
  330. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  331. If (!(Test-Path $Period)) {
  332. New-Item $Period
  333. }
  334. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  335. #Enables bloatware applications
  336. Write-Output "Adding Registry key to allow bloatware apps to return"
  337. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  338. If (!(Test-Path $registryPath)) {
  339. New-Item $registryPath
  340. }
  341. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  342. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  343. Write-Output "Setting Mixed Reality Portal value to 1"
  344. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  345. If (Test-Path $Holo) {
  346. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  347. }
  348. #Re-enables live tiles
  349. Write-Output "Enabling live tiles"
  350. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  351. If (!(Test-Path $Live)) {
  352. New-Item $Live
  353. }
  354. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  355. #Re-enables data collection
  356. Write-Output "Re-enabling data collection"
  357. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  358. If (!(Test-Path $DataCollection)) {
  359. New-Item $DataCollection
  360. }
  361. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  362. #Re-enables People Icon on Taskbar
  363. Write-Output "Enabling People icon on Taskbar"
  364. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  365. If (!(Test-Path $People)) {
  366. New-Item $People
  367. }
  368. Set-ItemProperty $People PeopleBand -Value 1
  369. #Re-enables suggestions on start menu
  370. Write-Output "Enabling suggestions on the Start Menu"
  371. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  372. If (!(Test-Path $Suggestions)) {
  373. New-Item $Suggestions
  374. }
  375. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  376. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  377. Write-Output "Enabling scheduled tasks that were disabled"
  378. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  379. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  380. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  381. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  382. Get-ScheduledTask DmClient | Enable-ScheduledTask
  383. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  384. Write-Output "Re-enabling and starting WAP Push Service"
  385. #Enable and start WAP Push Service
  386. Set-Service "dmwappushservice" -StartupType Automatic
  387. Start-Service "dmwappushservice"
  388. Write-Output "Re-enabling and starting the Diagnostics Tracking Service"
  389. #Enabling the Diagnostics Tracking Service
  390. Set-Service "DiagTrack" -StartupType Automatic
  391. Start-Service "DiagTrack"
  392. }
  393. Function Enable-EdgePDF {
  394. Write-Output "Setting Edge back to default"
  395. $NoPDF = "HKCR:\.pdf"
  396. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  397. $NoWithList = "HKCR:\.pdf\OpenWithList"
  398. #Sets edge back to default
  399. If (Get-ItemProperty $NoPDF NoOpenWith) {
  400. Remove-ItemProperty $NoPDF NoOpenWith
  401. }
  402. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  403. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  404. }
  405. If (Get-ItemProperty $NoProgids NoOpenWith) {
  406. Remove-ItemProperty $NoProgids NoOpenWith
  407. }
  408. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  409. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  410. }
  411. If (Get-ItemProperty $NoWithList NoOpenWith) {
  412. Remove-ItemProperty $NoWithList NoOpenWith
  413. }
  414. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  415. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  416. }
  417. #Removes an underscore '_' from the Registry key for Edge
  418. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  419. If (Test-Path $Edge2) {
  420. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  421. }
  422. }
  423. Function FixWhitelistedApps {
  424. [CmdletBinding()]
  425. Param()
  426. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  427. #Credit to abulgatz for these 4 lines of code
  428. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  429. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  430. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  431. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  432. }
  433. }
  434. Function UninstallOneDrive {
  435. Write-Output "Uninstalling OneDrive"
  436. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  437. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  438. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  439. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  440. Stop-Process -Name "OneDrive*"
  441. Start-Sleep 2
  442. If (!(Test-Path $onedrive)) {
  443. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  444. }
  445. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  446. Start-Sleep 2
  447. Write-Output "Stopping explorer"
  448. Start-Sleep 1
  449. .\taskkill.exe /F /IM explorer.exe
  450. Start-Sleep 3
  451. Write-Output "Removing leftover files"
  452. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  453. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  454. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  455. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  456. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  457. }
  458. Write-Output "Removing OneDrive from windows explorer"
  459. If (!(Test-Path $ExplorerReg1)) {
  460. New-Item $ExplorerReg1
  461. }
  462. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  463. If (!(Test-Path $ExplorerReg2)) {
  464. New-Item $ExplorerReg2
  465. }
  466. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  467. Write-Output "Restarting Explorer that was shut down before."
  468. Start explorer.exe -NoNewWindow
  469. }
  470. #GUI prompt Debloat/Revert options and GUI variables
  471. $Button = [Windows.MessageBoxButton]::YesNoCancel
  472. $ErrorIco = [Windows.MessageBoxImage]::Error
  473. $Warn = [Windows.MessageBoxImage]::Warning
  474. $Ask = 'The following will allow you to either Debloat Windows 10 or to revert changes made after Debloating Windows 10.
  475. Select "Yes" to Debloat Windows 10
  476. Select "No" to Revert changes made by this script
  477. Select "Cancel" to stop the script.'
  478. $EdgePdf = "Do you want to stop edge from taking over as the default PDF viewer?"
  479. $EdgePdf2 = "Do you want to revert changes that disabled Edge as the default PDF viewer?"
  480. $Reboot = "For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
  481. $OneDriveDelete = "Do you want to uninstall One Drive?"
  482. $Prompt1 = [Windows.MessageBox]::Show($Ask,"Debloat or Revert",$Button,$ErrorIco)
  483. Switch ($Prompt1) {
  484. #This will debloat Windows 10
  485. Yes {
  486. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  487. 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."
  488. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  489. Start-Sleep 1
  490. 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."
  491. Start-Debloat
  492. Write-Output "Bloatware removed."
  493. Start-Sleep 1
  494. Write-Output "Removing specific registry keys."
  495. Remove-Keys
  496. Write-Output "Leftover bloatware registry keys removed."
  497. Start-Sleep 1
  498. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  499. Start-Sleep 1
  500. FixWhitelistedApps
  501. Start-Sleep 1
  502. Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  503. Protect-Privacy
  504. Start-Sleep 1
  505. DisableCortana
  506. Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  507. Start-Sleep 1
  508. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  509. DisableDiagTrack
  510. Write-Output "Diagnostics Tracking Service disabled"
  511. Start-Sleep 1
  512. Write-Output "Disabling WAP push service"
  513. Start-Sleep 1
  514. DisableWAPPush
  515. Write-Output "WAP push service stopped and disabled"
  516. Start-Sleep 1; = $Debloat
  517. $Prompt2 = [Windows.MessageBox]::Show($EdgePdf,"Edge PDF",$Button,$Warn)
  518. Switch ($Prompt2) {
  519. Yes {
  520. Stop-EdgePDF
  521. Write-Output "Edge will no longer take over as the default PDF viewer."; = $Yes
  522. }
  523. No {
  524. = $No
  525. }
  526. Cancel {
  527. Exit-PSSession
  528. }
  529. }
  530. #Prompt asking to delete OneDrive
  531. $Prompt3 = [Windows.MessageBox]::Show($OneDriveDelete,"Delete OneDrive",$Button,$ErrorIco)
  532. Switch ($Prompt3) {
  533. Yes {
  534. UninstallOneDrive
  535. Write-Output "OneDrive is now removed from the computer."; = $Yes
  536. }
  537. No {
  538. = $No
  539. }
  540. Cancel {
  541. Exit-PSSession
  542. }
  543. }
  544. #Prompt asking if you'd like to reboot your machine
  545. $Prompt4 = [Windows.MessageBox]::Show($Reboot,"Reboot",$Button,$Warn)
  546. Switch ($Prompt4) {
  547. Yes {
  548. Write-Output "Unloading the HKCR drive..."
  549. Remove-PSDrive HKCR
  550. Start-Sleep 1
  551. Stop-Transcript
  552. Write-Output "Initiating reboot."
  553. Start-Sleep 2
  554. Restart-Computer; = $Yes
  555. }
  556. No {
  557. Write-Output "Unloading the HKCR drive..."
  558. Remove-PSDrive HKCR
  559. Start-Sleep 1
  560. Stop-Transcript
  561. Write-Output "Script has finished. Exiting."
  562. Start-Sleep 2
  563. Exit; = $No
  564. }
  565. Cancel {
  566. Exit-PSSession
  567. }
  568. }
  569. }
  570. No {
  571. Write-Output "Reverting changes..."
  572. 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."
  573. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  574. Revert-Changes; = $Revert
  575. #Prompt asking to revert edge changes as well
  576. $Prompt5 = [Windows.MessageBox]::Show($EdgePdf2,"Revert Edge",$Button,$ErrorIco)
  577. Switch ($Prompt5) {
  578. Yes {
  579. Enable-EdgePDF
  580. Write-Output "Edge will no longer be disabled from being used as the default Edge PDF viewer."; = $Yes
  581. }
  582. No { = $No
  583. }
  584. Cancel {
  585. Exit-PSSession
  586. }
  587. }
  588. #Prompt asking if you'd like to reboot your machine
  589. $Prompt6 = [Windows.MessageBox]::Show($Reboot,"Reboot",$Button,$Warn)
  590. Switch ($Prompt6) {
  591. Yes {
  592. Write-Output "Unloading the HKCR drive..."
  593. Remove-PSDrive HKCR
  594. Start-Sleep 1
  595. Write-Output "Initiating reboot."
  596. Stop-Transcript
  597. Start-Sleep 2
  598. Restart-Computer; = $Yes
  599. }
  600. No {
  601. Write-Output "Unloading the HKCR drive..."
  602. Remove-PSDrive HKCR
  603. Start-Sleep 1
  604. Write-Output "Script has finished. Exiting."
  605. Stop-Transcript
  606. Start-Sleep 2
  607. Exit; = $No
  608. }
  609. Cancel {
  610. Exit-PSSession
  611. }
  612. }
  613. }
  614. Cancel {
  615. Exit-PSSession
  616. }
  617. }