Windows10Debloater.ps1 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  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 will self elevate the script so with a UAC prompt since this script needs to be run as an Administrator in order to function properly.
  4. If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
  5. Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
  6. Start-Sleep 1
  7. Write-Host " 3"
  8. Start-Sleep 1
  9. Write-Host " 2"
  10. Start-Sleep 1
  11. Write-Host " 1"
  12. Start-Sleep 1
  13. Start-Process powershell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
  14. Exit
  15. }
  16. #no errors throughout
  17. $ErrorActionPreference = 'silentlycontinue'
  18. $DebloatFolder = "C:\Temp\Windows10Debloater"
  19. If (Test-Path $DebloatFolder) {
  20. Write-Output "$DebloatFolder exists. Skipping."
  21. }
  22. Else {
  23. Write-Output "The folder '$DebloatFolder' doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
  24. Start-Sleep 1
  25. New-Item -Path "$DebloatFolder" -ItemType Directory
  26. Write-Output "The folder $DebloatFolder was successfully created."
  27. }
  28. Start-Transcript -OutputDirectory "$DebloatFolder"
  29. Add-Type -AssemblyName PresentationCore, PresentationFramework
  30. Function DebloatAll {
  31. #Removes AppxPackages
  32. #Credit to /u/GavinEke for a modified version of my whitelist code
  33. $WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|`
  34. Microsoft.XboxGameCallableUI|Microsoft.XboxGamingOverlay|Microsoft.Xbox.TCUI|Microsoft.XboxGamingOverlay|Microsoft.XboxIdentityProvider|Microsoft.MicrosoftStickyNotes|Microsoft.MSPaint|Microsoft.WindowsCamera|.NET|Framework|`
  35. Microsoft.HEIFImageExtension|Microsoft.ScreenSketch|Microsoft.StorePurchaseApp|Microsoft.VP9VideoExtensions|Microsoft.WebMediaExtensions|Microsoft.WebpImageExtension|Microsoft.DesktopAppInstaller|WindSynthBerry|MIDIBerry|Slack'
  36. #NonRemovable Apps that where getting attempted and the system would reject the uninstall, speeds up debloat and prevents 'initalizing' overlay when removing apps
  37. $NonRemovable = '1527c705-839a-4832-9118-54d4Bd6a0c89|c5e2524a-ea46-4f67-841f-6a9465d9d515|E2A4F912-2574-4A75-9BB0-0D023378592B|F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE|InputApp|Microsoft.AAD.BrokerPlugin|Microsoft.AccountsControl|`
  38. Microsoft.BioEnrollment|Microsoft.CredDialogHost|Microsoft.ECApp|Microsoft.LockApp|Microsoft.MicrosoftEdgeDevToolsClient|Microsoft.MicrosoftEdge|Microsoft.PPIProjection|Microsoft.Win32WebViewHost|Microsoft.Windows.Apprep.ChxApp|`
  39. Microsoft.Windows.AssignedAccessLockApp|Microsoft.Windows.CapturePicker|Microsoft.Windows.CloudExperienceHost|Microsoft.Windows.ContentDeliveryManager|Microsoft.Windows.Cortana|Microsoft.Windows.NarratorQuickStart|`
  40. Microsoft.Windows.ParentalControls|Microsoft.Windows.PeopleExperienceHost|Microsoft.Windows.PinningConfirmationDialog|Microsoft.Windows.SecHealthUI|Microsoft.Windows.SecureAssessmentBrowser|Microsoft.Windows.ShellExperienceHost|`
  41. Microsoft.Windows.XGpuEjectDialog|Microsoft.XboxGameCallableUI|Windows.CBSPreview|windows.immersivecontrolpanel|Windows.PrintDialog|Microsoft.VCLibs.140.00|Microsoft.Services.Store.Engagement|Microsoft.UI.Xaml.2.0|*Nvidia*'
  42. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps -and $_.Name -NotMatch $NonRemovable} | Remove-AppxPackage
  43. Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps -and $_.Name -NotMatch $NonRemovable} | Remove-AppxPackage
  44. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps -and $_.PackageName -NotMatch $NonRemovable} | Remove-AppxProvisionedPackage -Online
  45. }
  46. Function DebloatBlacklist {
  47. $Bloatware = @(
  48. #Unnecessary Windows 10 AppX Apps
  49. "Microsoft.BingNews"
  50. "Microsoft.GetHelp"
  51. "Microsoft.Getstarted"
  52. "Microsoft.Messaging"
  53. "Microsoft.Microsoft3DViewer"
  54. "Microsoft.MicrosoftOfficeHub"
  55. "Microsoft.MicrosoftSolitaireCollection"
  56. "Microsoft.NetworkSpeedTest"
  57. "Microsoft.News"
  58. "Microsoft.Office.Lens"
  59. "Microsoft.Office.OneNote"
  60. "Microsoft.Office.Sway"
  61. "Microsoft.OneConnect"
  62. "Microsoft.People"
  63. "Microsoft.Print3D"
  64. "Microsoft.RemoteDesktop"
  65. "Microsoft.SkypeApp"
  66. "Microsoft.StorePurchaseApp"
  67. "Microsoft.Office.Todo.List"
  68. "Microsoft.Whiteboard"
  69. "Microsoft.WindowsAlarms"
  70. #"Microsoft.WindowsCamera"
  71. "microsoft.windowscommunicationsapps"
  72. "Microsoft.WindowsFeedbackHub"
  73. "Microsoft.WindowsMaps"
  74. "Microsoft.WindowsSoundRecorder"
  75. "Microsoft.Xbox.TCUI"
  76. "Microsoft.XboxApp"
  77. "Microsoft.XboxGameOverlay"
  78. "Microsoft.XboxIdentityProvider"
  79. "Microsoft.XboxSpeechToTextOverlay"
  80. "Microsoft.ZuneMusic"
  81. "Microsoft.ZuneVideo"
  82. #Sponsored Windows 10 AppX Apps
  83. #Add sponsored/featured apps to remove in the "*AppName*" format
  84. "*EclipseManager*"
  85. "*ActiproSoftwareLLC*"
  86. "*AdobeSystemsIncorporated.AdobePhotoshopExpress*"
  87. "*Duolingo-LearnLanguagesforFree*"
  88. "*PandoraMediaInc*"
  89. "*CandyCrush*"
  90. "*BubbleWitch3Saga*"
  91. "*Wunderlist*"
  92. "*Flipboard*"
  93. "*Twitter*"
  94. "*Facebook*"
  95. "*Spotify*"
  96. "*Minecraft*"
  97. "*Royal Revolt*"
  98. "*Sway*"
  99. "*Speed Test*"
  100. "*Dolby*"
  101. #Optional: Typically not removed but you can if you need to for some reason
  102. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*"
  103. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*"
  104. #"*Microsoft.BingWeather*"
  105. #"*Microsoft.MSPaint*"
  106. #"*Microsoft.MicrosoftStickyNotes*"
  107. #"*Microsoft.Windows.Photos*"
  108. #"*Microsoft.WindowsCalculator*"
  109. #"*Microsoft.WindowsStore*"
  110. )
  111. foreach ($Bloat in $Bloatware) {
  112. Get-AppxPackage -Name $Bloat| Remove-AppxPackage
  113. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online
  114. Write-Output "Trying to remove $Bloat."
  115. }
  116. }
  117. Function Remove-Keys {
  118. #These are the registry keys that it will delete.
  119. $Keys = @(
  120. #Remove Background Tasks
  121. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  122. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  123. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  124. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  125. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  126. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  127. #Windows File
  128. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  129. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  130. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  131. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  132. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  133. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  134. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  135. #Scheduled Tasks to delete
  136. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  137. #Windows Protocol Keys
  138. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  139. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  140. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  141. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  142. #Windows Share Target
  143. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  144. )
  145. #This writes the output of each key it is removing and also removes the keys listed above.
  146. ForEach ($Key in $Keys) {
  147. Write-Output "Removing $Key from registry"
  148. Remove-Item $Key -Recurse
  149. }
  150. }
  151. Function Protect-Privacy {
  152. #Disables Windows Feedback Experience
  153. Write-Output "Disabling Windows Feedback Experience program"
  154. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  155. If (Test-Path $Advertising) {
  156. Set-ItemProperty $Advertising Enabled -Value 0
  157. }
  158. #Stops Cortana from being used as part of your Windows Search Function
  159. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  160. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  161. If (Test-Path $Search) {
  162. Set-ItemProperty $Search AllowCortana -Value 0
  163. }
  164. #Disables Web Search in Start Menu
  165. Write-Output "Disabling Bing Search in Start Menu"
  166. $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  167. Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0
  168. If (!(Test-Path $WebSearch)) {
  169. New-Item $WebSearch
  170. }
  171. Set-ItemProperty $WebSearch DisableWebSearch -Value 1
  172. #Stops the Windows Feedback Experience from sending anonymous data
  173. Write-Output "Stopping the Windows Feedback Experience program"
  174. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  175. If (!(Test-Path $Period)) {
  176. New-Item $Period
  177. }
  178. Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
  179. #Prevents bloatware applications from returning and removes Start Menu suggestions
  180. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  181. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  182. $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  183. If (!(Test-Path $registryPath)) {
  184. New-Item $registryPath
  185. }
  186. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  187. If (!(Test-Path $registryOEM)) {
  188. New-Item $registryOEM
  189. }
  190. Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0
  191. Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0
  192. Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0
  193. Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0
  194. Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0
  195. Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0
  196. #Preping mixed Reality Portal for removal
  197. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  198. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  199. If (Test-Path $Holo) {
  200. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  201. }
  202. #Disables Wi-fi Sense
  203. Write-Output "Disabling Wi-Fi Sense"
  204. $WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
  205. $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
  206. $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
  207. If (!(Test-Path $WifiSense1)) {
  208. New-Item $WifiSense1
  209. }
  210. Set-ItemProperty $WifiSense1 Value -Value 0
  211. If (!(Test-Path $WifiSense2)) {
  212. New-Item $WifiSense2
  213. }
  214. Set-ItemProperty $WifiSense2 Value -Value 0
  215. Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
  216. #Disables live tiles
  217. Write-Output "Disabling live tiles"
  218. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  219. If (!(Test-Path $Live)) {
  220. New-Item $Live
  221. }
  222. Set-ItemProperty $Live NoTileApplicationNotification -Value 1
  223. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  224. Write-Output "Turning off Data Collection"
  225. $DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  226. $DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
  227. $DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  228. If (Test-Path $DataCollection1) {
  229. Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
  230. }
  231. If (Test-Path $DataCollection2) {
  232. Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
  233. }
  234. If (Test-Path $DataCollection3) {
  235. Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
  236. }
  237. #Disabling Location Tracking
  238. Write-Output "Disabling Location Tracking"
  239. $SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
  240. $LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
  241. If (!(Test-Path $SensorState)) {
  242. New-Item $SensorState
  243. }
  244. Set-ItemProperty $SensorState SensorPermissionState -Value 0
  245. If (!(Test-Path $LocationConfig)) {
  246. New-Item $LocationConfig
  247. }
  248. Set-ItemProperty $LocationConfig Status -Value 0
  249. #Disables People icon on Taskbar
  250. Write-Output "Disabling People icon on Taskbar"
  251. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  252. If (Test-Path $People) {
  253. Set-ItemProperty $People -Name PeopleBand -Value 0
  254. }
  255. #Disables scheduled tasks that are considered unnecessary
  256. Write-Output "Disabling scheduled tasks"
  257. Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
  258. Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
  259. Get-ScheduledTask Consolidator | Disable-ScheduledTask
  260. Get-ScheduledTask UsbCeip | Disable-ScheduledTask
  261. Get-ScheduledTask DmClient | Disable-ScheduledTask
  262. Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
  263. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  264. #Disabling the Diagnostics Tracking Service
  265. Stop-Service "DiagTrack"
  266. Set-Service "DiagTrack" -StartupType Disabled
  267. Write-Output "Removing CloudStore from registry if it exists"
  268. $CloudStore = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore'
  269. If (Test-Path $CloudStore) {
  270. Stop-Process Explorer.exe -Force
  271. Remove-Item $CloudStore -Recurse -Force
  272. Start-Process Explorer.exe -Wait
  273. }
  274. }
  275. Function DisableCortana {
  276. Write-Host "Disabling Cortana"
  277. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  278. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  279. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  280. If (!(Test-Path $Cortana1)) {
  281. New-Item $Cortana1
  282. }
  283. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  284. If (!(Test-Path $Cortana2)) {
  285. New-Item $Cortana2
  286. }
  287. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  288. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  289. If (!(Test-Path $Cortana3)) {
  290. New-Item $Cortana3
  291. }
  292. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  293. }
  294. Function EnableCortana {
  295. Write-Host "Re-enabling Cortana"
  296. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  297. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  298. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  299. If (!(Test-Path $Cortana1)) {
  300. New-Item $Cortana1
  301. }
  302. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  303. If (!(Test-Path $Cortana2)) {
  304. New-Item $Cortana2
  305. }
  306. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  307. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  308. If (!(Test-Path $Cortana3)) {
  309. New-Item $Cortana3
  310. }
  311. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  312. }
  313. Function Stop-EdgePDF {
  314. #Stops edge from taking over as the default .PDF viewer
  315. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  316. $NoPDF = "HKCR:\.pdf"
  317. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  318. $NoWithList = "HKCR:\.pdf\OpenWithList"
  319. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  320. New-ItemProperty $NoPDF NoOpenWith
  321. }
  322. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  323. New-ItemProperty $NoPDF NoStaticDefaultVerb
  324. }
  325. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  326. New-ItemProperty $NoProgids NoOpenWith
  327. }
  328. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  329. New-ItemProperty $NoProgids NoStaticDefaultVerb
  330. }
  331. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  332. New-ItemProperty $NoWithList NoOpenWith
  333. }
  334. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  335. New-ItemProperty $NoWithList NoStaticDefaultVerb
  336. }
  337. #Appends an underscore '_' to the Registry key for Edge
  338. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  339. If (Test-Path $Edge) {
  340. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  341. }
  342. }
  343. Function Revert-Changes {
  344. #This function will revert the changes you made when running the Start-Debloat function.
  345. #This line reinstalls all of the bloatware that was removed
  346. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  347. #Tells Windows to enable your advertising information.
  348. Write-Output "Re-enabling key to show advertisement information"
  349. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  350. If (Test-Path $Advertising) {
  351. Set-ItemProperty $Advertising Enabled -Value 1
  352. }
  353. #Enables Cortana to be used as part of your Windows Search Function
  354. Write-Output "Re-enabling Cortana to be used in your Windows Search"
  355. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  356. If (Test-Path $Search) {
  357. Set-ItemProperty $Search AllowCortana -Value 1
  358. }
  359. #Re-enables the Windows Feedback Experience for sending anonymous data
  360. Write-Output "Re-enabling Windows Feedback Experience"
  361. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  362. If (!(Test-Path $Period)) {
  363. New-Item $Period
  364. }
  365. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  366. #Enables bloatware applications
  367. Write-Output "Adding Registry key to allow bloatware apps to return"
  368. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  369. If (!(Test-Path $registryPath)) {
  370. New-Item $registryPath
  371. }
  372. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  373. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  374. Write-Output "Setting Mixed Reality Portal value to 1"
  375. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  376. If (Test-Path $Holo) {
  377. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  378. }
  379. #Re-enables live tiles
  380. Write-Output "Enabling live tiles"
  381. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  382. If (!(Test-Path $Live)) {
  383. New-Item $Live
  384. }
  385. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  386. #Re-enables data collection
  387. Write-Output "Re-enabling data collection"
  388. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  389. If (!(Test-Path $DataCollection)) {
  390. New-Item $DataCollection
  391. }
  392. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  393. #Re-enables People Icon on Taskbar
  394. Write-Output "Enabling People icon on Taskbar"
  395. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  396. If (!(Test-Path $People)) {
  397. New-Item $People
  398. }
  399. Set-ItemProperty $People PeopleBand -Value 1
  400. #Re-enables suggestions on start menu
  401. Write-Output "Enabling suggestions on the Start Menu"
  402. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  403. If (!(Test-Path $Suggestions)) {
  404. New-Item $Suggestions
  405. }
  406. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  407. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  408. Write-Output "Enabling scheduled tasks that were disabled"
  409. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  410. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  411. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  412. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  413. Get-ScheduledTask DmClient | Enable-ScheduledTask
  414. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  415. Write-Output "Re-enabling and starting WAP Push Service"
  416. #Enable and start WAP Push Service
  417. Set-Service "dmwappushservice" -StartupType Automatic
  418. Start-Service "dmwappushservice"
  419. Write-Output "Re-enabling and starting the Diagnostics Tracking Service"
  420. #Enabling the Diagnostics Tracking Service
  421. Set-Service "DiagTrack" -StartupType Automatic
  422. Start-Service "DiagTrack"
  423. Write-Output "Restoring 3D Objects in the 'My Computer' submenu in explorer"
  424. #Restoring 3D Objects in the 'My Computer' submenu in explorer
  425. Restore3dObjects
  426. }
  427. Function CheckDMWService {
  428. Param([switch]$Debloat)
  429. If (Get-Service -Name dmwappushservice | Where-Object {$_.StartType -eq "Disabled"}) {
  430. Set-Service -Name dmwappushservice -StartupType Automatic
  431. }
  432. If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  433. Start-Service -Name dmwappushservice
  434. }
  435. }
  436. Function Enable-EdgePDF {
  437. Write-Output "Setting Edge back to default"
  438. $NoPDF = "HKCR:\.pdf"
  439. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  440. $NoWithList = "HKCR:\.pdf\OpenWithList"
  441. #Sets edge back to default
  442. If (Get-ItemProperty $NoPDF NoOpenWith) {
  443. Remove-ItemProperty $NoPDF NoOpenWith
  444. }
  445. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  446. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  447. }
  448. If (Get-ItemProperty $NoProgids NoOpenWith) {
  449. Remove-ItemProperty $NoProgids NoOpenWith
  450. }
  451. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  452. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  453. }
  454. If (Get-ItemProperty $NoWithList NoOpenWith) {
  455. Remove-ItemProperty $NoWithList NoOpenWith
  456. }
  457. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  458. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  459. }
  460. #Removes an underscore '_' from the Registry key for Edge
  461. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  462. If (Test-Path $Edge2) {
  463. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  464. }
  465. }
  466. Function FixWhitelistedApps {
  467. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  468. #Credit to abulgatz for these 4 lines of code
  469. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  470. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  471. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  472. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  473. }
  474. }
  475. Function UninstallOneDrive {
  476. Write-Host "Checking for pre-existing files and folders located in the OneDrive folders..."
  477. Start-Sleep 1
  478. If (Test-Path "$env:USERPROFILE\OneDrive\*") {
  479. Write-Host "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
  480. Start-Sleep 1
  481. If (Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles") {
  482. Write-Host "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder."
  483. }
  484. else {
  485. If (!(Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles")) {
  486. Write-Host "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."
  487. New-item -Path "$env:USERPROFILE\Desktop" -Name "OneDriveBackupFiles"-ItemType Directory -Force
  488. Write-Host "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
  489. }
  490. }
  491. Start-Sleep 1
  492. Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
  493. Write-Host "Successfully moved all files/folders from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
  494. Start-Sleep 1
  495. Write-Host "Proceeding with the removal of OneDrive."
  496. Start-Sleep 1
  497. }
  498. Else {
  499. Write-Host "Either the OneDrive folder does not exist or there are no files to be found in the folder. Proceeding with removal of OneDrive."
  500. Start-Sleep 1
  501. Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
  502. $OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  503. If (!(Test-Path $OneDriveKey)) {
  504. Mkdir $OneDriveKey
  505. Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
  506. }
  507. Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
  508. }
  509. Write-Host "Uninstalling OneDrive. Please wait..."
  510. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  511. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  512. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  513. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  514. Stop-Process -Name "OneDrive*"
  515. Start-Sleep 2
  516. If (!(Test-Path $onedrive)) {
  517. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  518. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  519. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  520. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  521. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  522. Stop-Process -Name "OneDrive*"
  523. Start-Sleep 2
  524. If (!(Test-Path $onedrive)) {
  525. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  526. }
  527. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  528. Start-Sleep 2
  529. Write-Output "Stopping explorer"
  530. Start-Sleep 1
  531. taskkill.exe /F /IM explorer.exe
  532. Start-Sleep 3
  533. Write-Output "Removing leftover files"
  534. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  535. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  536. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  537. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  538. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  539. }
  540. Write-Output "Removing OneDrive from windows explorer"
  541. If (!(Test-Path $ExplorerReg1)) {
  542. New-Item $ExplorerReg1
  543. }
  544. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  545. If (!(Test-Path $ExplorerReg2)) {
  546. New-Item $ExplorerReg2
  547. }
  548. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  549. Write-Output "Restarting Explorer that was shut down before."
  550. Start-Process explorer.exe -NoNewWindow
  551. Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
  552. $OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  553. If (!(Test-Path $OneDriveKey)) {
  554. Mkdir $OneDriveKey
  555. }
  556. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  557. Start-Sleep 2
  558. Write-Host "Stopping explorer"
  559. Start-Sleep 1
  560. taskkill.exe /F /IM explorer.exe
  561. Start-Sleep 3
  562. Write-Host "Removing leftover files"
  563. If (Test-Path "$env:USERPROFILE\OneDrive") {
  564. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  565. }
  566. If (Test-Path "$env:LOCALAPPDATA\Microsoft\OneDrive") {
  567. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  568. }
  569. If (Test-Path "$env:PROGRAMDATA\Microsoft OneDrive") {
  570. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  571. }
  572. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  573. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  574. }
  575. Write-Host "Removing OneDrive from windows explorer"
  576. If (!(Test-Path $ExplorerReg1)) {
  577. New-Item $ExplorerReg1
  578. }
  579. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  580. If (!(Test-Path $ExplorerReg2)) {
  581. New-Item $ExplorerReg2
  582. }
  583. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  584. Write-Host "Restarting Explorer that was shut down before."
  585. Start-Process explorer.exe -NoNewWindow
  586. Write-Host "OneDrive has been successfully uninstalled!"
  587. Remove-item env:OneDrive
  588. }
  589. }
  590. Function UnpinStart {
  591. #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
  592. #Unpins all tiles from the Start Menu
  593. Write-Host "Unpinning all tiles from the start menu"
  594. (New-Object -Com Shell.Application).
  595. NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
  596. Items() |
  597. % { $_.Verbs() } |
  598. ? {$_.Name -match 'Un.*pin from Start'} |
  599. % {$_.DoIt()}
  600. }
  601. Function Remove3dObjects {
  602. #Removes 3D Objects from the 'My Computer' submenu in explorer
  603. Write-Host "Removing 3D Objects from explorer 'My Computer' submenu"
  604. $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  605. $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  606. If (Test-Path $Objects32) {
  607. Remove-Item $Objects32 -Recurse
  608. }
  609. If (Test-Path $Objects64) {
  610. Remove-Item $Objects64 -Recurse
  611. }
  612. }
  613. Function Restore3dObjects {
  614. #Restores 3D Objects from the 'My Computer' submenu in explorer
  615. Write-Host "Restoring 3D Objects from explorer 'My Computer' submenu"
  616. $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  617. $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  618. If (!(Test-Path $Objects32)) {
  619. New-Item $Objects32
  620. }
  621. If (!(Test-Path $Objects64)) {
  622. New-Item $Objects64
  623. }
  624. }
  625. #Interactive prompt Debloat/Revert options
  626. $Button = [Windows.MessageBoxButton]::YesNoCancel
  627. $ErrorIco = [Windows.MessageBoxImage]::Error
  628. $Warn = [Windows.MessageBoxImage]::Warning
  629. $Ask = 'The following will allow you to either Debloat Windows 10 or to revert changes made after Debloating Windows 10.
  630. Select "Yes" to Debloat Windows 10
  631. Select "No" to Revert changes made by this script
  632. Select "Cancel" to stop the script.'
  633. $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."
  634. $EdgePdf = "Do you want to stop edge from taking over as the default PDF viewer?"
  635. $EdgePdf2 = "Do you want to revert changes that disabled Edge as the default PDF viewer?"
  636. $Reboot = "For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
  637. $OneDriveDelete = "Do you want to uninstall One Drive?"
  638. $Unpin = "Do you want to unpin all items from the Start menu?"
  639. $InstallNET = "Do you want to install .NET 3.5?"
  640. $Prompt1 = [Windows.MessageBox]::Show($Ask, "Debloat or Revert", $Button, $ErrorIco)
  641. Switch ($Prompt1) {
  642. #This will debloat Windows 10
  643. Yes {
  644. #Everything is specific prompt
  645. $Prompt2 = [Windows.MessageBox]::Show($EverythingorSpecific, "Everything or Specific", $Button, $Warn)
  646. switch ($Prompt2) {
  647. Yes {
  648. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  649. Write-Host "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."
  650. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  651. Start-Sleep 1
  652. Write-Host "Uninstalling bloatware, please wait."
  653. DebloatAll
  654. Write-Host "Bloatware removed."
  655. Start-Sleep 1
  656. Write-Host "Removing specific registry keys."
  657. Remove-Keys
  658. Write-Host "Leftover bloatware registry keys removed."
  659. Start-Sleep 1
  660. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  661. Start-Sleep 1
  662. FixWhitelistedApps
  663. Start-Sleep 1
  664. Write-Host "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  665. Protect-Privacy
  666. Start-Sleep 1
  667. DisableCortana
  668. Write-Host "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  669. Start-Sleep 1
  670. Write-Host "Stopping and disabling Diagnostics Tracking Service"
  671. DisableDiagTrack
  672. Write-Host "Diagnostics Tracking Service disabled"
  673. Start-Sleep 1
  674. Write-Host "Disabling WAP push service"
  675. DisableWAPPush
  676. Start-Sleep 1
  677. Write-Host "Re-enabling DMWAppushservice if it was disabled"
  678. CheckDMWService
  679. Start-Sleep 1
  680. Write-Host "Removing 3D Objects from the 'My Computer' submenu in explorer"
  681. Remove3dObjects
  682. Start-Sleep 1
  683. }
  684. No {
  685. #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
  686. Write-Host "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."
  687. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  688. Start-Sleep 1
  689. Write-Host "Uninstalling bloatware, please wait."
  690. DebloatBlacklist
  691. Write-Host "Bloatware removed."
  692. Start-Sleep 1
  693. Write-Host "Removing specific registry keys."
  694. Remove-Keys
  695. Write-Host "Leftover bloatware registry keys removed."
  696. Start-Sleep 1
  697. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  698. Start-Sleep 1
  699. FixWhitelistedApps
  700. Start-Sleep 1
  701. Write-Host "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
  702. Protect-Privacy
  703. Start-Sleep 1
  704. DisableCortana
  705. Write-Host "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
  706. Start-Sleep 1
  707. Write-Host "Stopping and disabling Diagnostics Tracking Service"
  708. DisableDiagTrack
  709. Write-Host "Diagnostics Tracking Service disabled"
  710. Start-Sleep 1
  711. Write-Host "Disabling WAP push service"
  712. Start-Sleep 1
  713. DisableWAPPush
  714. Write-Host "Re-enabling DMWAppushservice if it was disabled"
  715. CheckDMWService
  716. Start-Sleep 1
  717. }
  718. }
  719. #Disabling EdgePDF prompt
  720. $Prompt3 = [Windows.MessageBox]::Show($EdgePdf, "Edge PDF", $Button, $Warn)
  721. Switch ($Prompt3) {
  722. Yes {
  723. Stop-EdgePDF
  724. Write-Host "Edge will no longer take over as the default PDF viewer."
  725. }
  726. No {
  727. Write-Host "You chose not to stop Edge from taking over as the default PDF viewer."
  728. }
  729. }
  730. #Prompt asking to delete OneDrive
  731. $Prompt4 = [Windows.MessageBox]::Show($OneDriveDelete, "Delete OneDrive", $Button, $ErrorIco)
  732. Switch ($Prompt4) {
  733. Yes {
  734. UninstallOneDrive
  735. Write-Host "OneDrive is now removed from the computer."
  736. }
  737. No {
  738. Write-Host "You have chosen to skip removing OneDrive from your machine."
  739. }
  740. }
  741. #Prompt asking if you'd like to unpin all start items
  742. $Prompt5 = [Windows.MessageBox]::Show($Unpin, "Unpin", $Button, $ErrorIco)
  743. Switch ($Prompt5) {
  744. Yes {
  745. UnpinStart
  746. Write-Host "Start Apps unpined."
  747. }
  748. No {
  749. Write-Host "Apps will remain pinned to the start menu."
  750. }
  751. }
  752. #Prompt asking if you want to install .NET
  753. $Prompt6 = [Windows.MessageBox]::Show($InstallNET, "Install .Net", $Button, $Warn)
  754. Switch ($Prompt6) {
  755. Yes {
  756. Write-Host "Initializing the installation of .NET 3.5..."
  757. DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
  758. Write-Host ".NET 3.5 has been successfully installed!"
  759. }
  760. No {
  761. Write-Host "Skipping .NET install."
  762. }
  763. }
  764. #Prompt asking if you'd like to reboot your machine
  765. $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
  766. Switch ($Prompt7) {
  767. Yes {
  768. Write-Host "Unloading the HKCR drive..."
  769. Remove-PSDrive HKCR
  770. Start-Sleep 1
  771. Write-Host "Initiating reboot."
  772. Stop-Transcript
  773. Start-Sleep 2
  774. Restart-Computer
  775. }
  776. No {
  777. Write-Host "Unloading the HKCR drive..."
  778. Remove-PSDrive HKCR
  779. Start-Sleep 1
  780. Write-Host "Script has finished. Exiting."
  781. Stop-Transcript
  782. Start-Sleep 2
  783. Exit
  784. }
  785. }
  786. }
  787. No {
  788. Write-Host "Reverting changes..."
  789. Write-Host "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."
  790. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  791. Revert-Changes
  792. #Prompt asking to revert edge changes as well
  793. $Prompt6 = [Windows.MessageBox]::Show($EdgePdf2, "Revert Edge", $Button, $ErrorIco)
  794. Switch ($Prompt6) {
  795. Yes {
  796. Enable-EdgePDF
  797. Write-Host "Edge will no longer be disabled from being used as the default Edge PDF viewer."
  798. }
  799. No {
  800. Write-Host "You have chosen to keep the setting that disallows Edge to be the default PDF viewer."
  801. }
  802. }
  803. #Prompt asking if you'd like to reboot your machine
  804. $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
  805. Switch ($Prompt7) {
  806. Yes {
  807. Write-Host "Unloading the HKCR drive..."
  808. Remove-PSDrive HKCR
  809. Start-Sleep 1
  810. Write-Host "Initiating reboot."
  811. Stop-Transcript
  812. Start-Sleep 2
  813. Restart-Computer
  814. }
  815. No {
  816. Write-Host "Unloading the HKCR drive..."
  817. Remove-PSDrive HKCR
  818. Start-Sleep 1
  819. Write-Host "Script has finished. Exiting."
  820. Stop-Transcript
  821. Start-Sleep 2
  822. Exit
  823. }
  824. }
  825. }
  826. }