Windows10Debloater.ps1 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  2. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  3. #Checks for the script running as admin and if it's not then restarts the script in admin
  4. Add-Type -AssemblyName PresentationCore,PresentationFramework
  5. If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
  6. Start-Process powershell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
  7. Exit
  8. }
  9. If (Test-Path "C:\Windows10Debloater") {
  10. Write-Output "C:\Windows10Debloater exists. Skipping."
  11. }
  12. Else {
  13. Write-Output "The folder 'C:\Windows10Debloater' doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
  14. Start-Sleep 1
  15. New-Item -Path "C:\Windows10Debloater" -ItemType Directory
  16. }
  17. Start-Transcript -OutputDirectory "C:\Windows10Debloater"
  18. #no errors throughout
  19. $ErrorActionPreference = 'silentlycontinue'
  20. Function Start-Debloat {
  21. [CmdletBinding()]
  22. Param()
  23. #Removes AppxPackages
  24. #Credit to /u/GavinEke for a modified version of my whitelist code
  25. [regex]$WhitelistedApps = 'Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|Microsoft.XboxGameCallableUI|Microsoft.XboxGamingOverlay|Microsoft.Xbox.TCUI'
  26. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
  27. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online
  28. }
  29. Function Remove-Keys {
  30. [CmdletBinding()]
  31. Param()
  32. #These are the registry keys that it will delete.
  33. $Keys = @(
  34. #Remove Background Tasks
  35. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  36. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  37. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  38. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  39. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  40. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  41. #Windows File
  42. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  43. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  44. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  45. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  46. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  47. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  48. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  49. #Scheduled Tasks to delete
  50. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  51. #Windows Protocol Keys
  52. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  53. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  54. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  55. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  56. #Windows Share Target
  57. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  58. )
  59. #This writes the output of each key it is removing and also removes the keys listed above.
  60. ForEach ($Key in $Keys) {
  61. Write-Output "Removing $Key from registry"
  62. Remove-Item $Key -Recurse
  63. }
  64. }
  65. Function Protect-Privacy {
  66. [CmdletBinding()]
  67. Param()
  68. #Disables Windows Feedback Experience
  69. Write-Output "Disabling Windows Feedback Experience program"
  70. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  71. If (Test-Path $Advertising) {
  72. Set-ItemProperty $Advertising -Name Enabled -Value 0 -Verbose
  73. }
  74. #Stops Cortana from being used as part of your Windows Search Function
  75. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  76. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  77. If (Test-Path $Search) {
  78. Set-ItemProperty $Search -Name AllowCortana -Value 0 -Verbose
  79. }
  80. #Stops the Windows Feedback Experience from sending anonymous data
  81. Write-Output "Stopping the Windows Feedback Experience program"
  82. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  83. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  84. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  85. If (!(Test-Path $Period3)) {
  86. mkdir $Period1
  87. mkdir $Period2
  88. mkdir $Period3
  89. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose
  90. }
  91. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  92. #Prevents bloatware applications from returning
  93. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  94. If (!(Test-Path $registryPath)) {
  95. Mkdir $registryPath
  96. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose
  97. }
  98. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  99. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  100. If (Test-Path $Holo) {
  101. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  102. }
  103. #Disables live tiles
  104. Write-Output "Disabling live tiles"
  105. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  106. If (!(Test-Path $Live)) {
  107. mkdir $Live
  108. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  109. }
  110. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  111. Write-Output "Turning off Data Collection"
  112. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  113. If (Test-Path $DataCollection) {
  114. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  115. }
  116. #Disables People icon on Taskbar
  117. Write-Output "Disabling People icon on Taskbar"
  118. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  119. If (!(Test-Path $People)) {
  120. mkdir $People
  121. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  122. }
  123. #Disables suggestions on start menu
  124. Write-Output "Disabling suggestions on the Start Menu"
  125. If ('HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager') {
  126. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  127. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
  128. }
  129. #Disables scheduled tasks that are considered unnecessary
  130. Write-Output "Disabling scheduled tasks"
  131. Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask
  132. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask
  133. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask
  134. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask
  135. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask
  136. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask
  137. }
  138. Function Stop-EdgePDF {
  139. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  140. #Stops edge from taking over as the default .PDF viewer
  141. If (!(Get-ItemProperty 'HKCR:\.pdf' -Name NoOpenWith)) {
  142. $NoOpen = 'HKCR:\.pdf'
  143. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  144. }
  145. If (!(Get-ItemProperty 'HKCR:\.pdf' -Name NoStaticDefaultVerb)) {
  146. $NoStatic = 'HKCR:\.pdf'
  147. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  148. }
  149. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoOpenWith)) {
  150. $NoOpen = 'HKCR:\.pdf\OpenWithProgids'
  151. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  152. }
  153. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoStaticDefaultVerb)) {
  154. $NoStatic = 'HKCR:\.pdf\OpenWithProgids'
  155. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  156. }
  157. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoOpenWith)) {
  158. $NoOpen = 'HKCR:\.pdf\OpenWithList'
  159. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  160. }
  161. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoStaticDefaultVerb)) {
  162. $NoStatic = 'HKCR:\.pdf\OpenWithList'
  163. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  164. }
  165. #Appends an underscore '_' to the Registry key for Edge
  166. If ('HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723') {
  167. $Edge = 'HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'
  168. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_ -Verbose
  169. }
  170. }
  171. Function Revert-Changes {
  172. [CmdletBinding()]
  173. Param()
  174. #This function will revert the changes you made when running the Start-Debloat function.
  175. #This line reinstalls all of the bloatware that was removed
  176. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  177. Write-Output "Re-enabling key to show advertisement information"
  178. #Tells Windows to enable your advertising information.
  179. If ('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo') {
  180. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  181. Set-ItemProperty $Advertising -Name Enabled -Value 1 -Verbose
  182. }
  183. #Enables Cortana to be used as part of your Windows Search Function
  184. Write-Output "Re-enabling Cortana to be used in your Windows Search"
  185. If ('HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search') {
  186. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  187. Set-ItemProperty $Search -Name AllowCortana -Value 1 -Verbose
  188. }
  189. #Re-enables the Windows Feedback Experience for sending anonymous data
  190. Write-Output "Re-enabling Windows Feedback Experience"
  191. If (!('HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds')) {
  192. mkdir 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  193. $Period = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  194. New-Item $Period
  195. Set-ItemProperty -Name PeriodInNanoSeconds -Value 1 -Verbose
  196. }
  197. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  198. #Enables bloatware applications
  199. If ('HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent') {
  200. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  201. Mkdir $registryPath
  202. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 0 -Verbose
  203. }
  204. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  205. Write-Output "Setting Mixed Reality Portal value to 1"
  206. If ('HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic') {
  207. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  208. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 1 -Verbose
  209. }
  210. #Re-enables live tiles
  211. Write-Output "Enabling live tiles"
  212. If ('HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications') {
  213. mkdir 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  214. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  215. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 0 -Verbose
  216. }
  217. Write-Output "Changing the 'Cloud Content' registry key value to 1 to allow bloatware apps to reinstall"
  218. #Prevents bloatware applications from returning
  219. If ("HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent\") {
  220. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  221. Mkdir $registryPath
  222. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose
  223. }
  224. #Re-enables data collection
  225. Write-Output "Re-enabling data collection"
  226. If ('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection') {
  227. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  228. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 1 -Verbose
  229. }
  230. #Re-enables People Icon on Taskbar
  231. Write-Output "Enabling People icon on Taskbar"
  232. If ('HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People') {
  233. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  234. New-ItemProperty $People -Name PeopleBand -Value 1 -Verbose
  235. }
  236. #Re-enables suggestions on start menu
  237. Write-Output "Enabling suggestions on the Start Menu"
  238. If ('HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager') {
  239. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  240. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 1 -Verbose
  241. }
  242. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  243. Write-Output "Enabling scheduled tasks that were disabled"
  244. Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Enable-ScheduledTask
  245. Get-ScheduledTask -TaskName XblGameSaveTask | Enable-ScheduledTask
  246. Get-ScheduledTask -TaskName Consolidator | Enable-ScheduledTask
  247. Get-ScheduledTask -TaskName UsbCeip | Enable-ScheduledTask
  248. Get-ScheduledTask -TaskName DmClient | Enable-ScheduledTask
  249. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Enable-ScheduledTask
  250. }
  251. Function Enable-EdgePDF {
  252. Write-Output "Setting Edge back to default"
  253. #Sets edge back to default
  254. If (Get-ItemProperty 'HKCR:\.pdf' -Name NoOpenWith) {
  255. $NoOpen = 'HKCR:\.pdf'
  256. Remove-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  257. }
  258. If (Get-ItemProperty 'HKCR:\.pdf' -Name NoStaticDefaultVerb) {
  259. $NoStatic = 'HKCR:\.pdf'
  260. Remove-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  261. }
  262. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoOpenWith) {
  263. $NoOpen = 'HKCR:\.pdf\OpenWithProgids'
  264. Remove-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  265. }
  266. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoStaticDefaultVerb) {
  267. $NoStatic = 'HKCR:\.pdf\OpenWithProgids'
  268. Remove-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  269. }
  270. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoOpenWith) {
  271. $NoOpen = 'HKCR:\.pdf\OpenWithList'
  272. Remove-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  273. }
  274. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoStaticDefaultVerb) {
  275. $NoStatic = 'HKCR:\.pdf\OpenWithList'
  276. Remove-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  277. }
  278. #Removes an underscore '_' from the Registry key for Edge
  279. If ('HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723') {
  280. $Edge = 'HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'
  281. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723 -Verbose
  282. }
  283. }
  284. Function FixWhitelistedApps {
  285. [CmdletBinding()]
  286. Param()
  287. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  288. #Credit to abulgatz for these 4 lines of code
  289. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  290. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  291. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  292. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  293. }
  294. }
  295. #GUI prompt Debloat/Revert options and GUI variables
  296. $Button = [Windows.MessageBoxButton]::YesNo
  297. $ErrorIco = [Windows.MessageBoxImage]::Error
  298. $Warn = [Windows.MessageBoxImage]::Warning
  299. $Ask = 'The following will allow you to either Debloat Windows 10, or to revert changes made after Debloating Windows 10.
  300. Choose "Yes" to Debloat Windows 10
  301. Choose "No" to revert changes made by this script.'
  302. $EdgePdf = 'Do you want to stop edge from taking over as the default PDF viewer?'
  303. $EdgePdf2 = 'Do you want to revert changes that disabled Edge as the default PDF viewer?'
  304. $Reboot = 'For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?'
  305. $Prompt1 = [Windows.MessageBox]::Show($Ask,'Debloat or Revert',$Button,$ErrorIco)
  306. Switch ($Prompt1) {
  307. #This will debloat Windows 10
  308. Yes {
  309. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  310. 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."
  311. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  312. Start-Sleep 1
  313. Write-Output "Uninstalling bloatware, please wait."
  314. Start-Debloat
  315. Write-Output "Bloatware removed."
  316. Start-Sleep 1
  317. Write-Output "Removing specific registry keys."
  318. Remove-Keys
  319. Write-Output "Leftover bloatware registry keys removed."
  320. Start-Sleep 1
  321. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  322. Start-Sleep 1
  323. FixWhitelistedApps
  324. Start-Sleep 1
  325. Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  326. Protect-Privacy
  327. Write-Output "Cortana disabled from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  328. Start-Sleep 1; $PublishSettings = $Debloat
  329. $Prompt2 = [Windows.MessageBox]::Show($EdgePdf,'Edge PDF',$Button,$Warn)
  330. Switch ($Prompt2) {
  331. Yes {
  332. Stop-EdgePDF
  333. Write-Output "Edge will no longer take over as the default PDF viewer."; $PublishSettings = $Yes
  334. }
  335. No {
  336. $PublishSettings = $No
  337. }
  338. }
  339. #Prompt asking if you'd like to reboot your machine
  340. $Prompt3 = [Windows.MessageBox]::Show($Reboot,'Reboot',$Button,$Warn)
  341. Switch ($Prompt3) {
  342. Yes {
  343. Write-Output "Unloading the HKCR drive..."
  344. Remove-PSDrive HKCR
  345. Start-Sleep 1
  346. Stop-Transcript
  347. Write-Output "Initiating reboot."
  348. Start-Sleep 2
  349. Restart-Computer; $PublishSettings = $Yes
  350. }
  351. No {
  352. Write-Output "Unloading the HKCR drive..."
  353. Remove-PSDrive HKCR
  354. Start-Sleep 1
  355. Stop-Transcript
  356. Write-Output "Script has finished. Exiting."
  357. Start-Sleep 2
  358. Exit; $PublishSettings = $No
  359. }
  360. }
  361. }
  362. No {
  363. Write-Output "Reverting changes..."
  364. 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."
  365. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  366. Revert-Changes; $PublishSettings = $Revert
  367. #Prompt asking to revert edge changes as well
  368. $Prompt4 = [Windows.MessageBox]::Show($EdgePdf2,'Revert Edge',$Button,$ErrorIco)
  369. Switch ($Prompt4) {
  370. Yes {
  371. Enable-EdgePDF
  372. Write-Output "Edge will no longer be disabled from being used as the default Edge PDF viewer."; $PublishSettings = $Yes
  373. }
  374. No {$PublishSettings = $No}
  375. }
  376. #Prompt asking if you'd like to reboot your machine
  377. $Prompt5 = [Windows.MessageBox]::Show($Reboot,'Reboot',$Button,$Warn)
  378. Switch ($Prompt5) {
  379. Yes {
  380. Write-Output "Unloading the HKCR drive..."
  381. Remove-PSDrive HKCR
  382. Start-Sleep 1
  383. Write-Output "Initiating reboot."
  384. Stop-Transcript
  385. Start-Sleep 2
  386. Restart-Computer; $PublishSettings = $Yes
  387. }
  388. No {
  389. Write-Output "Unloading the HKCR drive..."
  390. Remove-PSDrive HKCR
  391. Start-Sleep 1
  392. Write-Output "Script has finished. Exiting."
  393. Stop-Transcript
  394. Start-Sleep 2
  395. Exit; $PublishSettings = $No
  396. }
  397. }
  398. }
  399. }