Windows10Debloater.ps1 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. Function Start-Debloat {
  4. [CmdletBinding()]
  5. Param()
  6. #Removes AppxPackages
  7. Get-AppxPackage -AllUsers |
  8. Where-Object {$_.name -notlike "*Microsoft.FreshPaint*"} |
  9. Where-Object {$_.name -notlike "*Microsoft.WindowsCalculator*"} |
  10. Where-Object {$_.name -notlike "*Microsoft.WindowsStore*"} |
  11. Where-Object {$_.name -notlike "*Microsoft.Windows.Photos*"} |
  12. Remove-AppxPackage -ErrorAction SilentlyContinue
  13. #Removes AppxProvisionedPackages
  14. Get-AppxProvisionedPackage -online |
  15. Where-Object {$_.packagename -notlike "*Microsoft.FreshPaint*"} |
  16. Where-Object {$_.packagename -notlike "*Microsoft.WindowsCalculator*"} |
  17. Where-Object {$_.name -notlike "*Microsoft.WindowsStore*"} |
  18. Where-Object {$_.name -notlike "*Microsoft.Windows.Photos*"} |
  19. Remove-AppxProvisionedPackage -online -ErrorAction SilentlyContinue
  20. }
  21. Function Remove-Keys {
  22. [CmdletBinding()]
  23. Param()
  24. #These are the registry keys that it will delete.
  25. $Keys = @(
  26. #Remove Background Tasks
  27. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  28. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  29. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  30. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  31. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  32. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  33. #Windows File
  34. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  35. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  36. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  37. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  38. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  39. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  40. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  41. #Scheduled Tasks to delete
  42. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  43. #Windows Protocol Keys
  44. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  45. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  46. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  47. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  48. #Windows Share Target
  49. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  50. )
  51. #This writes the output of each key it is removing and also removes the keys listed above.
  52. ForEach ($Key in $Keys) {
  53. Write-Output "Removing $Key from registry"
  54. Remove-Item $Key -Recurse -ErrorAction SilentlyContinue
  55. }
  56. }
  57. Function Protect-Privacy {
  58. [CmdletBinding()]
  59. Param()
  60. #Disables Windows Feedback Experience
  61. Write-Output "Disabling Windows Feedback Experience program"
  62. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  63. If (Test-Path $Advertising) {
  64. Set-ItemProperty $Advertising -Name Enabled -Value 0 -Verbose
  65. }
  66. #Stops Cortana from being used as part of your Windows Search Function
  67. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  68. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  69. If (Test-Path $Search) {
  70. Set-ItemProperty $Search -Name AllowCortana -Value 0 -Verbose
  71. }
  72. #Stops the Windows Feedback Experience from sending anonymous data
  73. Write-Output "Stopping the Windows Feedback Experience program"
  74. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  75. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  76. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  77. If (!(Test-Path $Period3)) {
  78. mkdir $Period1 -ErrorAction SilentlyContinue
  79. mkdir $Period2 -ErrorAction SilentlyContinue
  80. mkdir $Period3 -ErrorAction SilentlyContinue
  81. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
  82. }
  83. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  84. #Prevents bloatware applications from returning
  85. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  86. If (!(Test-Path $registryPath)) {
  87. Mkdir $registryPath -ErrorAction SilentlyContinue
  88. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  89. }
  90. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  91. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  92. If (Test-Path $Holo) {
  93. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  94. }
  95. #Disables live tiles
  96. Write-Output "Disabling live tiles"
  97. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  98. If (!(Test-Path $Live)) {
  99. mkdir $Live -ErrorAction SilentlyContinue
  100. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  101. }
  102. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  103. Write-Output "Turning off Data Collection"
  104. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  105. If (Test-Path $DataCollection) {
  106. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  107. }
  108. #Disables People icon on Taskbar
  109. Write-Output "Disabling People icon on Taskbar"
  110. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  111. If (!(Test-Path $People)) {
  112. mkdir $People -ErrorAction SilentlyContinue
  113. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  114. }
  115. #Disables suggestions on start menu
  116. Write-Output "Disabling suggestions on the Start Menu"
  117. If ('HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager') {
  118. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  119. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 Verbose
  120. }
  121. #Disables scheduled tasks that are considered unnecessary
  122. Write-Output "Disabling scheduled tasks"
  123. Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask
  124. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask
  125. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask
  126. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask
  127. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask
  128. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask
  129. }
  130. Function Stop-EdgePDF {
  131. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  132. #Stops edge from taking over as the default .PDF viewer
  133. If (!(Get-ItemProperty 'HKCR:\.pdf' -Name NoOpenWith)) {
  134. $NoOpen = 'HKCR:\.pdf'
  135. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
  136. }
  137. If (!(Get-ItemProperty 'HKCR:\.pdf' -Name NoStaticDefaultVerb)) {
  138. $NoStatic = 'HKCR:\.pdf'
  139. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
  140. }
  141. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoOpenWith)) {
  142. $NoOpen = 'HKCR:\.pdf\OpenWithProgids'
  143. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
  144. }
  145. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoStaticDefaultVerb)) {
  146. $NoStatic = 'HKCR:\.pdf\OpenWithProgids'
  147. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
  148. }
  149. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoOpenWith)) {
  150. $NoOpen = 'HKCR:\.pdf\OpenWithList'
  151. New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
  152. }
  153. If (!(Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoStaticDefaultVerb)) {
  154. $NoStatic = 'HKCR:\.pdf\OpenWithList'
  155. New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
  156. }
  157. #Appends an underscore '_' to the Registry key for Edge
  158. If ('HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723') {
  159. $Edge = 'HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'
  160. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_ -Verbose
  161. }
  162. }
  163. Function Revert-Changes {
  164. [CmdletBinding()]
  165. Param()
  166. #This function will revert the changes you made when running the Start-Debloat function.
  167. #This line reinstalls all of the bloatware that was removed
  168. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} -ErrorAction SilentlyContinue
  169. Write-Output "Re-enabling key to show advertisement information"
  170. #Tells Windows to enable your advertising information.
  171. If ('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo') {
  172. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  173. Set-ItemProperty $Advertising -Name Enabled -Value 1 -Verbose
  174. }
  175. #Enables Cortana to be used as part of your Windows Search Function
  176. Write-Output "Re-enabling Cortana to be used in your Windows Search"
  177. If ('HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search') {
  178. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  179. Set-ItemProperty $Search -Name AllowCortana -Value 1 -Verbose
  180. }
  181. #Re-enables the Windows Feedback Experience for sending anonymous data
  182. Write-Output "Re-enabling Windows Feedback Experience"
  183. If (!('HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds')) {
  184. mkdir 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  185. $Period = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  186. New-Item $Period -ErrorAction SilentlyContinue
  187. Set-ItemProperty -Name PeriodInNanoSeconds -Value 1 -Verbose
  188. }
  189. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  190. #Enables bloatware applications
  191. If ('HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent') {
  192. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  193. Mkdir $registryPath -ErrorAction SilentlyContinue
  194. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 0 -Verbose -ErrorAction SilentlyContinue
  195. }
  196. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  197. Write-Output "Setting Mixed Reality Portal value to 1"
  198. If ('HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic') {
  199. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  200. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 1 -Verbose
  201. }
  202. #Re-enables live tiles
  203. Write-Output "Enabling live tiles"
  204. If ('HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications') {
  205. mkdir 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications' -ErrorAction SilentlyContinue
  206. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  207. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 0 -Verbose -ErrorAction SilentlyContinue
  208. }
  209. Write-Output "Changing the 'Cloud Content' registry key value to 1 to allow bloatware apps to reinstall"
  210. #Prevents bloatware applications from returning
  211. If ("HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent\") {
  212. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  213. Mkdir $registryPath -ErrorAction SilentlyContinue
  214. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  215. }
  216. #Re-enables data collection
  217. Write-Output "Re-enabling data collection"
  218. If ('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection') {
  219. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  220. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 1 -Verbose
  221. }
  222. #Re-enables People Icon on Taskbar
  223. Write-Output "Enabling People icon on Taskbar"
  224. If ('HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People') {
  225. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  226. New-ItemProperty $People -Name PeopleBand -Value 1 -Verbose -ErrorAction SilentlyContinue
  227. }
  228. #Re-enables suggestions on start menu
  229. Write-Output "Enabling suggestions on the Start Menu"
  230. If ('HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager') {
  231. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  232. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 1 -Verbose
  233. }
  234. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  235. Write-Output "Enabling scheduled tasks that were disabled"
  236. Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Enable-ScheduledTask
  237. Get-ScheduledTask -TaskName XblGameSaveTask | Enable-ScheduledTask
  238. Get-ScheduledTask -TaskName Consolidator | Enable-ScheduledTask
  239. Get-ScheduledTask -TaskName UsbCeip | Enable-ScheduledTask
  240. Get-ScheduledTask -TaskName DmClient | Enable-ScheduledTask
  241. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Enable-ScheduledTask
  242. }
  243. Function Enable-EdgePDF {
  244. Write-Output "Setting Edge back to default"
  245. #Sets edge back to default
  246. If (Get-ItemProperty 'HKCR:\.pdf' -Name NoOpenWith) {
  247. $NoOpen = 'HKCR:\.pdf'
  248. Remove-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  249. }
  250. If (Get-ItemProperty 'HKCR:\.pdf' -Name NoStaticDefaultVerb) {
  251. $NoStatic = 'HKCR:\.pdf'
  252. Remove-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  253. }
  254. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoOpenWith) {
  255. $NoOpen = 'HKCR:\.pdf\OpenWithProgids'
  256. Remove-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  257. }
  258. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithProgids' -Name NoStaticDefaultVerb) {
  259. $NoStatic = 'HKCR:\.pdf\OpenWithProgids'
  260. Remove-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  261. }
  262. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoOpenWith) {
  263. $NoOpen = 'HKCR:\.pdf\OpenWithList'
  264. Remove-ItemProperty $NoOpen -Name NoOpenWith -Verbose
  265. }
  266. If (Get-ItemProperty 'HKCR:\.pdf\OpenWithList' -Name NoStaticDefaultVerb) {
  267. $NoStatic = 'HKCR:\.pdf\OpenWithList'
  268. Remove-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose
  269. }
  270. #Removes an underscore '_' from the Registry key for Edge
  271. If ('HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723') {
  272. $Edge = 'HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'
  273. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723 -Verbose
  274. }
  275. }
  276. #This switch will ask you if you'd like to run the script as interactive or silently. Depending on your selection, yes will be interactive, no will be silent.
  277. Write-Output "How would you like to run this script?"
  278. $ReadHost = Read-Host " ( Interactive / Silent ) "
  279. Switch ($ReadHost) {
  280. Interactive {
  281. #Switch statement containing Debloat/Revert options
  282. Write-Output "The following options will allow you to either Debloat Windows 10, or to revert changes made after Debloating Windows 10.
  283. Choose 'Debloat' to Debloat Windows 10 or choose 'Revert' to revert changes."
  284. $Readhost = Read-Host " ( Debloat / Revert ) "
  285. Switch ($ReadHost) {
  286. #This will debloat Windows 10
  287. Debloat {
  288. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  289. 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."
  290. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  291. Sleep 1
  292. Write-Output "Uninstalling bloatware, please wait."
  293. Start-Debloat
  294. Write-Output "Bloatware removed."
  295. Sleep 1
  296. Write-Output "Removing specific registry keys."
  297. Remove-Keys
  298. Write-Output "Leftover bloatware registry keys removed."
  299. Sleep 1
  300. Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  301. Protect-Privacy
  302. Write-Output "Cortana disabled from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  303. Sleep 1; $PublishSettings = $true
  304. Write-Output "Do you want to stop edge from taking over as the default PDF viewer?"
  305. $ReadHost = Read-Host " (Yes / No ) "
  306. Switch ($ReadHost) {
  307. Yes {
  308. Stop-EdgePDF
  309. Write-Output "Edge will no longer take over as the default PDF viewer."; $PublishSettings = $true
  310. }
  311. No {$PublishSettings = $false}
  312. }
  313. #Switch statement asking if you'd like to reboot your machine
  314. Write-Output "For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
  315. $Readhost = Read-Host " ( Yes / No ) "
  316. Switch ($Readhost) {
  317. Yes {
  318. Write-Output "Unloading the HKCR drive..."
  319. Remove-PSDrive HKCR
  320. Sleep 1
  321. Write-Output "Initiating reboot."; $PublishSettings = $true
  322. Sleep 2
  323. Restart-Computer
  324. }
  325. No {
  326. Write-Output "Unloading the HKCR drive..."
  327. Remove-PSDrive HKCR
  328. Sleep 1
  329. Write-Output "Script has finished. Exiting."
  330. Sleep 2
  331. Exit; $PublishSettings = $false
  332. }
  333. }
  334. }
  335. Revert {
  336. Write-Output "Reverting changes..."; $PublishSettings = $false
  337. 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."
  338. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  339. Revert-Changes
  340. Write-Output "Do you want to revert changes that disabled Edge as the default PDF viewer?"
  341. $ReadHost = Read-Host " (Yes / No ) "
  342. Switch ($ReadHost) {
  343. Yes {
  344. Enable-EdgePDF
  345. Write-Output "Edge will no longer be disabled from being used as the default Edge PDF viewer."; $PublishSettings = $true
  346. }
  347. No {$PublishSettings = $false}
  348. }
  349. #Switch statement asking if you'd like to reboot your machine
  350. Write-Output "For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
  351. $Readhost = Read-Host " ( Yes / No ) "
  352. Switch ($Readhost) {
  353. Yes {
  354. Write-Output "Unloading the HKCR drive..."
  355. Remove-PSDrive HKCR
  356. Sleep 1
  357. Write-Output "Initiating reboot."; $PublishSettings = $true
  358. Sleep 2
  359. Restart-Computer
  360. }
  361. No {
  362. Write-Output "Unloading the HKCR drive..."
  363. Remove-PSDrive HKCR
  364. Sleep 1
  365. Write-Output "Script has finished. Exiting."
  366. Sleep 2
  367. Exit; $PublishSettings = $false
  368. }
  369. }
  370. }
  371. }
  372. }
  373. Silent {
  374. Start-Debloat
  375. Remove-Keys
  376. Protect-Privacy; $PublishSettings = $false
  377. }
  378. }