Windows10Debloater.ps1 28 KB

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