Windows10Debloater.ps1 36 KB

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