Windows10Debloater.ps1 28 KB

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