Windows10Debloater.ps1 36 KB

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