Windows10Debloater.ps1 25 KB

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