Windows10DebloaterSilent.ps1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. #This is the switch parameter for running this script as a 'silent' script, for use in MDT images or any type of mass deployment without user interaction.
  4. param([switch]$Debloat)
  5. #Creates a PSDrive to be able to access the 'HKCR' tree
  6. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  7. Function Start-Debloat {
  8. param
  9. ([switch]$Debloat)
  10. #Removes AppxPackages
  11. Get-AppxPackage -AllUsers |
  12. Where-Object {$_.name -notlike "*Microsoft.FreshPaint*"} |
  13. Where-Object {$_.name -notlike "*Microsoft.WindowsCalculator*"} |
  14. Where-Object {$_.name -notlike "*Microsoft.WindowsStore*"} |
  15. Where-Object {$_.name -notlike "*Microsoft.Windows.Photos*"} |
  16. Remove-AppxPackage -ErrorAction SilentlyContinue
  17. #Removes AppxProvisionedPackages
  18. Get-AppxProvisionedPackage -online |
  19. Where-Object {$_.packagename -notlike "*Microsoft.FreshPaint*"} |
  20. Where-Object {$_.packagename -notlike "*Microsoft.WindowsCalculator*"} |
  21. Where-Object {$_.name -notlike "*Microsoft.WindowsStore*"} |
  22. Where-Object {$_.name -notlike "*Microsoft.Windows.Photos*"} |
  23. Remove-AppxProvisionedPackage -online -ErrorAction SilentlyContinue
  24. }
  25. Function Remove-Keys {
  26. Param([switch]$Debloat)
  27. #These are the registry keys that it will delete.
  28. $Keys = @(
  29. #Remove Background Tasks
  30. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  31. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  32. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  33. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  34. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  35. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  36. #Windows File
  37. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  38. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  39. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  40. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  41. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  42. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  43. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  44. #Scheduled Tasks to delete
  45. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  46. #Windows Protocol Keys
  47. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  48. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  49. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  50. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  51. #Windows Share Target
  52. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  53. )
  54. #This writes the output of each key it is removing and also removes the keys listed above.
  55. ForEach ($Key in $Keys) {
  56. Write-Output "Removing $Key from registry"
  57. Remove-Item $Key -Recurse -ErrorAction SilentlyContinue
  58. }
  59. }
  60. Function Protect-Privacy {
  61. Param([switch]$Debloat)
  62. #Creates a PSDrive to be able to access the 'HKCR' tree
  63. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  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 -Name Enabled -Value 0 -Verbose
  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 -Name AllowCortana -Value 0 -Verbose
  75. }
  76. #Stops the Windows Feedback Experience from sending anonymous data
  77. Write-Output "Stopping the Windows Feedback Experience program"
  78. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  79. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  80. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  81. If (!(Test-Path $Period3)) {
  82. mkdir $Period1 -ErrorAction SilentlyContinue
  83. mkdir $Period2 -ErrorAction SilentlyContinue
  84. mkdir $Period3 -ErrorAction SilentlyContinue
  85. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
  86. }
  87. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  88. #Prevents bloatware applications from returning
  89. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  90. If (!(Test-Path $registryPath)) {
  91. Mkdir $registryPath -ErrorAction SilentlyContinue
  92. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  93. }
  94. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  95. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  96. If (Test-Path $Holo) {
  97. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  98. }
  99. #Disables live tiles
  100. Write-Output "Disabling live tiles"
  101. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  102. If (!(Test-Path $Live)) {
  103. mkdir $Live -ErrorAction SilentlyContinue
  104. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  105. }
  106. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  107. Write-Output "Turning off Data Collection"
  108. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  109. If (Test-Path $DataCollection) {
  110. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  111. }
  112. #Disables People icon on Taskbar
  113. Write-Output "Disabling People icon on Taskbar"
  114. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  115. If (!(Test-Path $People)) {
  116. mkdir $People -ErrorAction SilentlyContinue
  117. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  118. }
  119. #Disables suggestions on start menu
  120. Write-Output "Disabling suggestions on the Start Menu"
  121. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  122. If (Test-Path $Suggestions) {
  123. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
  124. }
  125. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  126. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  127. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  128. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  129. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  130. reg unload HKU\Default_User
  131. #Disables scheduled tasks that are considered unnecessary
  132. Write-Output "Disabling scheduled tasks"
  133. Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask
  134. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask
  135. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask
  136. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask
  137. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask
  138. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask
  139. }
  140. Function Stop-EdgePDF {
  141. param([switch]$StopEdgePDF)
  142. #Stops edge from taking over as the default .PDF viewer
  143. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  144. $NoOpen = 'HKCR:\.pdf'
  145. If (!(Get-ItemProperty $NoOpen -Name NoOpenWith)) {
  146. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
  147. }
  148. $NoStatic = 'HKCR:\.pdf'
  149. If (!(Get-ItemProperty $NoStatic -Name NoStaticDefaultVerb)) {
  150. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
  151. }
  152. $NoOpen = 'HKCR:\.pdf\OpenWithProgids'
  153. If (!(Get-ItemProperty $NoOpen -Name NoOpenWith)) {
  154. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
  155. }
  156. $NoStatic = 'HKCR:\.pdf\OpenWithProgids'
  157. If (!(Get-ItemProperty $NoStatic -Name NoStaticDefaultVerb)) {
  158. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
  159. }
  160. $NoOpen = 'HKCR:\.pdf\OpenWithList'
  161. If (!(Get-ItemProperty $NoOpen -Name NoOpenWith)) {
  162. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
  163. }
  164. $NoStatic = 'HKCR:\.pdf\OpenWithList'
  165. If (!(Get-ItemProperty $NoStatic -Name NoStaticDefaultVerb)) {
  166. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
  167. }
  168. #Appends an underscore '_' to the Registry key for Edge
  169. $Edge = 'HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'
  170. If (Test-Path $Edge) {
  171. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_ -Verbose
  172. }
  173. }
  174. Write-Output "Removing bloatware apps."
  175. Start-Debloat
  176. Write-Output "Removing leftover bloatware registry keys."
  177. Remove-Keys
  178. Write-Output "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  179. Protect-Privacy
  180. Write-Output "Stopping Edge from taking over as the default PDF Viewer."
  181. Stop-EdgePDF
  182. Write-Output "Finished all tasks."