Windows10DebloaterGUI.ps1 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  1. <#
  2. $EnableEdgePDFTakeover.Text = "Enable Edge PDF Takeover"
  3. $EnableEdgePDFTakeover.Width = 185
  4. $EnableEdgePDFTakeover.Height = 35
  5. $EnableEdgePDFTakeover.Location = New-Object System.Drawing.Point(155, 260)
  6. #>
  7. #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.
  8. $ErrorActionPreference = 'SilentlyContinue'
  9. $Button = [System.Windows.MessageBoxButton]::YesNoCancel
  10. $ErrorIco = [System.Windows.MessageBoxImage]::Error
  11. $Ask = 'Do you want to run this as an Administrator?
  12. Select "Yes" to Run as an Administrator
  13. Select "No" to not run this as an Administrator
  14. Select "Cancel" to stop the script.'
  15. If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
  16. $Prompt = [System.Windows.MessageBox]::Show($Ask, "Run as an Administrator or not?", $Button, $ErrorIco)
  17. Switch ($Prompt) {
  18. #This will debloat Windows 10
  19. Yes {
  20. Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
  21. Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
  22. Exit
  23. }
  24. No {
  25. Break
  26. }
  27. }
  28. }
  29. #Unnecessary Windows 10 AppX apps that will be removed by the blacklist.
  30. $global:Bloatware = @(
  31. "Microsoft.BingNews"
  32. "Microsoft.GetHelp"
  33. "Microsoft.Getstarted"
  34. "Microsoft.Messaging"
  35. "Microsoft.Microsoft3DViewer"
  36. "Microsoft.MicrosoftOfficeHub"
  37. "Microsoft.MicrosoftSolitaireCollection"
  38. "Microsoft.NetworkSpeedTest"
  39. "Microsoft.News" # Issue 77
  40. "Microsoft.Office.Lens" # Issue 77
  41. "Microsoft.Office.OneNote"
  42. "Microsoft.Office.Sway"
  43. "Microsoft.OneConnect"
  44. "Microsoft.People"
  45. "Microsoft.Print3D"
  46. "Microsoft.RemoteDesktop" # Issue 120
  47. "Microsoft.SkypeApp"
  48. "Microsoft.StorePurchaseApp"
  49. "Microsoft.Office.Todo.List" # Issue 77
  50. "Microsoft.Whiteboard" # Issue 77
  51. "Microsoft.WindowsAlarms"
  52. "microsoft.windowscommunicationsapps"
  53. "Microsoft.WindowsFeedbackHub"
  54. "Microsoft.WindowsMaps"
  55. "Microsoft.WindowsSoundRecorder"
  56. "Microsoft.Xbox.TCUI"
  57. "Microsoft.XboxApp"
  58. "Microsoft.XboxGameOverlay"
  59. "Microsoft.XboxGamingOverlay"
  60. "Microsoft.XboxIdentityProvider"
  61. "Microsoft.XboxSpeechToTextOverlay"
  62. "Microsoft.ZuneMusic"
  63. "Microsoft.ZuneVideo"
  64. #Sponsored Windows 10 AppX Apps
  65. #Add sponsored/featured apps to remove in the "*AppName*" format
  66. "EclipseManager"
  67. "ActiproSoftwareLLC"
  68. "AdobeSystemsIncorporated.AdobePhotoshopExpress"
  69. "Duolingo-LearnLanguagesforFree"
  70. "PandoraMediaInc"
  71. "CandyCrush"
  72. "Wunderlist"
  73. "Flipboard"
  74. "Twitter"
  75. "Facebook"
  76. "Spotify" # Issue 123
  77. "Minecraft"
  78. "Royal Revolt"
  79. "Sway" # Issue 77
  80. "Dolby" # Issue 78
  81. #Optional: Typically not removed but you can if you need to for some reason
  82. #"Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe"
  83. #"Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe"
  84. #"Microsoft.BingWeather"
  85. )
  86. #Valuable Windows 10 AppX apps that most people want to keep. Protected from DeBloat All.
  87. #Credit to /u/GavinEke for a modified version of my whitelist code
  88. $global:WhiteListedApps = @(
  89. "Microsoft.WindowsCalculator" # Microsoft removed legacy calculator
  90. "Microsoft.WindowsStore" # Issue 1
  91. "Microsoft.Windows.Photos" # Microsoft disabled/hid legacy photo viewer
  92. "CanonicalGroupLimited.UbuntuonWindows" # Issue 10
  93. "Microsoft.Xbox.TCUI" # Issue 25, 91 Many home users want to play games
  94. "Microsoft.XboxApp"
  95. "Microsoft.XboxGameOverlay"
  96. "Microsoft.XboxGamingOverlay" # Issue 25, 91 Many home users want to play games
  97. "Microsoft.XboxIdentityProvider" # Issue 25, 91 Many home users want to play games
  98. "Microsoft.XboxSpeechToTextOverlay"
  99. "Microsoft.MicrosoftStickyNotes" # Issue 33 New functionality.
  100. "Microsoft.MSPaint" # Issue 32 This is Paint3D, legacy paint still exists in Windows 10
  101. "Microsoft.WindowsCamera" # Issue 65 New functionality.
  102. "\.NET"
  103. "Microsoft.HEIFImageExtension" # Issue 68
  104. "Microsoft.ScreenSketch" # Issue 55: Looks like Microsoft will be axing snipping tool and using Snip & Sketch going forward
  105. "Microsoft.StorePurchaseApp" # Issue 68
  106. "Microsoft.VP9VideoExtensions" # Issue 68
  107. "Microsoft.WebMediaExtensions" # Issue 68
  108. "Microsoft.WebpImageExtension" # Issue 68
  109. "Microsoft.DesktopAppInstaller" # Issue 68
  110. "WindSynthBerry" # Issue 68
  111. "MIDIBerry" # Issue 68
  112. "Slack" # Issue 83
  113. "*Nvidia*" # Issue 198
  114. "Microsoft.MixedReality.Portal" # Issue 195
  115. )
  116. #NonRemovable Apps that where getting attempted and the system would reject the uninstall, speeds up debloat and prevents 'initalizing' overlay when removing apps
  117. $NonRemovables = Get-AppxPackage -AllUsers | Where-Object { $_.NonRemovable -eq $true } | ForEach { $_.Name }
  118. $NonRemovables += Get-AppxPackage | Where-Object { $_.NonRemovable -eq $true } | ForEach { $_.Name }
  119. $NonRemovables += Get-AppxProvisionedPackage -Online | Where-Object { $_.NonRemovable -eq $true } | ForEach { $_.DisplayName }
  120. $NonRemovables = $NonRemovables | Sort-Object -Unique
  121. if ($NonRemovables -eq $null ) {
  122. # the .NonRemovable property doesn't exist until version 18xx. Use a hard-coded list instead.
  123. #WARNING: only use exact names here - no short names or wildcards
  124. $NonRemovables = @(
  125. "1527c705-839a-4832-9118-54d4Bd6a0c89"
  126. "c5e2524a-ea46-4f67-841f-6a9465d9d515"
  127. "E2A4F912-2574-4A75-9BB0-0D023378592B"
  128. "F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE"
  129. "InputApp"
  130. "Microsoft.AAD.BrokerPlugin"
  131. "Microsoft.AccountsControl"
  132. "Microsoft.BioEnrollment"
  133. "Microsoft.CredDialogHost"
  134. "Microsoft.ECApp"
  135. "Microsoft.LockApp"
  136. "Microsoft.MicrosoftEdgeDevToolsClient"
  137. "Microsoft.MicrosoftEdge"
  138. "Microsoft.PPIProjection"
  139. "Microsoft.Win32WebViewHost"
  140. "Microsoft.Windows.Apprep.ChxApp"
  141. "Microsoft.Windows.AssignedAccessLockApp"
  142. "Microsoft.Windows.CapturePicker"
  143. "Microsoft.Windows.CloudExperienceHost"
  144. "Microsoft.Windows.ContentDeliveryManager"
  145. "Microsoft.Windows.Cortana"
  146. "Microsoft.Windows.HolographicFirstRun" # Added 1709
  147. "Microsoft.Windows.NarratorQuickStart"
  148. "Microsoft.Windows.OOBENetworkCaptivePortal" # Added 1709
  149. "Microsoft.Windows.OOBENetworkConnectionFlow" # Added 1709
  150. "Microsoft.Windows.ParentalControls"
  151. "Microsoft.Windows.PeopleExperienceHost"
  152. "Microsoft.Windows.PinningConfirmationDialog"
  153. "Microsoft.Windows.SecHealthUI" # Issue 117 Windows Defender
  154. "Microsoft.Windows.SecondaryTileExperience" # Added 1709
  155. "Microsoft.Windows.SecureAssessmentBrowser"
  156. "Microsoft.Windows.ShellExperienceHost"
  157. "Microsoft.Windows.XGpuEjectDialog"
  158. "Microsoft.XboxGameCallableUI" # Issue 91
  159. "Windows.CBSPreview"
  160. "windows.immersivecontrolpanel"
  161. "Windows.PrintDialog"
  162. "Microsoft.VCLibs.140.00"
  163. "Microsoft.Services.Store.Engagement"
  164. "Microsoft.UI.Xaml.2.0"
  165. )
  166. }
  167. # import library code - located relative to this script
  168. Function dotInclude() {
  169. Param(
  170. [Parameter(Mandatory)]
  171. [string]$includeFile
  172. )
  173. # Look for the file in the same directory as this script
  174. $scriptPath = $PSScriptRoot
  175. if ( $PSScriptRoot -eq $null -and $psISE) {
  176. $scriptPath = (Split-Path -Path $psISE.CurrentFile.FullPath)
  177. }
  178. if ( test-path $scriptPath\$includeFile ) {
  179. # import and immediately execute the requested file
  180. . $scriptPath\$includeFile
  181. }
  182. }
  183. # Override built-in blacklist/whitelist with user defined lists
  184. dotInclude 'custom-lists.ps1'
  185. #convert to regular expression to allow for the super-useful -match operator
  186. $global:BloatwareRegex = $global:Bloatware -join '|'
  187. $global:WhiteListedAppsRegex = $global:WhiteListedApps -join '|'
  188. # This form was created using POSHGUI.com a free online gui designer for PowerShell
  189. Add-Type -AssemblyName System.Windows.Forms
  190. [System.Windows.Forms.Application]::EnableVisualStyles()
  191. #region begin GUI
  192. $Form = New-Object System.Windows.Forms.Form
  193. $Form.ClientSize = '800,500'
  194. $Form.Text = "Windows10Debloater"
  195. $Form.TopMost = $false
  196. $Debloat = New-Object System.Windows.Forms.Label
  197. $Debloat.Text = "Debloat Options"
  198. $Debloat.AutoSize = $true
  199. $Debloat.Width = 25
  200. $Debloat.Height = 10
  201. $Debloat.Location = New-Object System.Drawing.Point(9, 8)
  202. $Debloat.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  203. $CustomizeBlacklists = New-Object System.Windows.Forms.Button
  204. $CustomizeBlacklists.Text = "Customize Blacklist"
  205. $CustomizeBlacklists.Width = 140
  206. $CustomizeBlacklists.Height = 40
  207. $CustomizeBlacklists.Location = New-Object System.Drawing.Point(9, 32)
  208. $CustomizeBlacklists.Font = 'Microsoft Sans Serif,10'
  209. $RemoveAllBloatware = New-Object System.Windows.Forms.Button
  210. $RemoveAllBloatware.Text = "Remove All Bloatware"
  211. $RemoveAllBloatware.Width = 142
  212. $RemoveAllBloatware.Height = 40
  213. $RemoveAllBloatware.Location = New-Object System.Drawing.Point(8, 79)
  214. $RemoveAllBloatware.Font = 'Microsoft Sans Serif,10'
  215. $RemoveBlacklist = New-Object System.Windows.Forms.Button
  216. $RemoveBlacklist.Text = "Remove Bloatware With Customized Blacklist"
  217. $RemoveBlacklist.Width = 205
  218. $RemoveBlacklist.Height = 37
  219. $RemoveBlacklist.Location = New-Object System.Drawing.Point(9, 124)
  220. $RemoveBlacklist.Font = 'Microsoft Sans Serif,10'
  221. $Label1 = New-Object System.Windows.Forms.Label
  222. $Label1.Text = "Revert Registry Changes"
  223. $Label1.AutoSize = $true
  224. $Label1.Width = 25
  225. $Label1.Height = 10
  226. $Label1.Location = New-Object System.Drawing.Point(254, 7)
  227. $Label1.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  228. $RevertChange = New-Object System.Windows.Forms.Button
  229. $RevertChange.Text = "Revert Registry Changes"
  230. $RevertChange.Width = 113
  231. $RevertChange.Height = 36
  232. $RevertChange.Location = New-Object System.Drawing.Point(254, 32)
  233. $RevertChange.Font = 'Microsoft Sans Serif,10'
  234. $Label2 = New-Object System.Windows.Forms.Label
  235. $Label2.Text = "Optional Changes/Fixes"
  236. $Label2.AutoSize = $true
  237. $Label2.Width = 25
  238. $Label2.Height = 10
  239. $Label2.Location = New-Object System.Drawing.Point(9, 193)
  240. $Label2.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  241. $DisableCortana = New-Object System.Windows.Forms.Button
  242. $DisableCortana.Text = "Disable Cortana"
  243. $DisableCortana.Width = 111
  244. $DisableCortana.Height = 36
  245. $DisableCortana.Location = New-Object System.Drawing.Point(9, 217)
  246. $DisableCortana.Font = 'Microsoft Sans Serif,10'
  247. $EnableCortana = New-Object System.Windows.Forms.Button
  248. $EnableCortana.Text = "Enable Cortana"
  249. $EnableCortana.Width = 112
  250. $EnableCortana.Height = 36
  251. $EnableCortana.Location = New-Object System.Drawing.Point(9, 260)
  252. $EnableCortana.Font = 'Microsoft Sans Serif,10'
  253. $StopEdgePDFTakeover = New-Object System.Windows.Forms.Button
  254. $StopEdgePDFTakeover.Text = "Stop Edge PDF Takeover"
  255. $StopEdgePDFTakeover.Width = 175
  256. $StopEdgePDFTakeover.Height = 35
  257. $StopEdgePDFTakeover.Location = New-Object System.Drawing.Point(155, 217)
  258. $StopEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  259. $EnableEdgePDFTakeover = New-Object System.Windows.Forms.Button
  260. $EnableEdgePDFTakeover.Text = "Enable Edge PDF Takeover"
  261. $EnableEdgePDFTakeover.Width = 185
  262. $EnableEdgePDFTakeover.Height = 35
  263. $EnableEdgePDFTakeover.Location = New-Object System.Drawing.Point(155, 260)
  264. $EnableEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  265. $DisableTelemetry = New-Object System.Windows.Forms.Button
  266. $DisableTelemetry.Text = "Disable Telemetry/Tasks"
  267. $DisableTelemetry.Width = 152
  268. $DisableTelemetry.Height = 35
  269. $DisableTelemetry.Location = New-Object System.Drawing.Point(365, 260)
  270. $DisableTelemetry.Font = 'Microsoft Sans Serif,10'
  271. $RemoveRegkeys = New-Object System.Windows.Forms.Button
  272. $RemoveRegkeys.Text = "Remove Bloatware Regkeys"
  273. $RemoveRegkeys.Width = 188
  274. $RemoveRegkeys.Height = 35
  275. $RemoveRegkeys.Location = New-Object System.Drawing.Point(540, 260)
  276. $RemoveRegkeys.Font = 'Microsoft Sans Serif,10'
  277. $UnpinStartMenuTiles = New-Object System.Windows.Forms.Button
  278. $UnpinStartMenuTiles.Text = "Unpin Tiles From Start Menu"
  279. $UnpinStartMenuTiles.Width = 190
  280. $UnpinStartMenuTiles.Height = 35
  281. $UnpinStartMenuTiles.Location = New-Object System.Drawing.Point(540, 217)
  282. $UnpinStartMenuTiles.Font = 'Microsoft Sans Serif,10'
  283. $RemoveOnedrive = New-Object System.Windows.Forms.Button
  284. $RemoveOnedrive.Text = "Uninstall OneDrive"
  285. $RemoveOnedrive.Width = 152
  286. $RemoveOnedrive.Height = 35
  287. $RemoveOnedrive.Location = New-Object System.Drawing.Point(365, 217)
  288. $RemoveOnedrive.Font = 'Microsoft Sans Serif,10'
  289. #$FixWhitelist = New-Object System.Windows.Forms.Button
  290. #$FixWhitelist.Text = "Fix Whitelisted Apps"
  291. #$FixWhitelist.Width = 130
  292. #$FixWhitelist.Height = 37
  293. #$FixWhitelist.Location = New-Object System.Drawing.Point(254, 74)
  294. #$FixWhitelist.Font = 'Microsoft Sans Serif,10'
  295. $InstallNet35 = New-Object System.Windows.Forms.Button
  296. $InstallNet35.Text = "Install .NET v3.5"
  297. $InstallNet35.Width = 152
  298. $InstallNet35.Height = 39
  299. $InstallNet35.Location = New-Object System.Drawing.Point(169, 335)
  300. $InstallNet35.Font = 'Microsoft Sans Serif,10'
  301. $EnableDarkMode = New-Object System.Windows.Forms.Button
  302. $EnableDarkMode.Text = "Enable Dark Mode"
  303. $EnableDarkMode.Width = 152
  304. $EnableDarkMode.Height = 39
  305. $EnableDarkMode.Location = New-Object System.Drawing.Point(9, 335)
  306. $EnableDarkMode.Font = 'Microsoft Sans Serif,10'
  307. $DisableDarkMode = New-Object System.Windows.Forms.Button
  308. $DisableDarkMode.Text = "Disable Dark Mode"
  309. $DisableDarkMode.Width = 152
  310. $DisableDarkMode.Height = 39
  311. $DisableDarkMode.Location = New-Object System.Drawing.Point(9, 385)
  312. $DisableDarkMode.Font = 'Microsoft Sans Serif,10'
  313. $Form.controls.AddRange(@($Debloat, $CustomizeBlacklists, $RemoveAllBloatware, $RemoveBlacklist, $Label1, $RevertChange, $Label2, $DisableCortana, $EnableCortana, $StopEdgePDFTakeover, $EnableEdgePDFTakeover, $DisableTelemetry, $RemoveRegkeys, $UnpinStartMenuTiles, $RemoveOnedrive, $FixWhitelist, $RemoveBloatNoBlacklist, $InstallNet35, $EnableDarkMode, $DisableDarkMode))
  314. $DebloatFolder = "C:\Temp\Windows10Debloater"
  315. If (Test-Path $DebloatFolder) {
  316. Write-Host "${DebloatFolder} exists. Skipping."
  317. }
  318. Else {
  319. Write-Host "The folder ${DebloatFolder} doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
  320. Start-Sleep 1
  321. New-Item -Path "${DebloatFolder}" -ItemType Directory
  322. Write-Host "The folder ${DebloatFolder} was successfully created."
  323. }
  324. Start-Transcript -OutputDirectory "${DebloatFolder}"
  325. #region gui events {
  326. $CustomizeBlacklists.Add_Click( {
  327. $CustomizeForm = New-Object System.Windows.Forms.Form
  328. $CustomizeForm.ClientSize = '600,400'
  329. $CustomizeForm.Text = "Customize Whitelist and Blacklist"
  330. $CustomizeForm.TopMost = $false
  331. $CustomizeForm.AutoScroll = $true
  332. $SaveList = New-Object System.Windows.Forms.Button
  333. $SaveList.Text = "Save custom Whitelist and Blacklist to custom-lists.ps1"
  334. $SaveList.AutoSize = $true
  335. $SaveList.Location = New-Object System.Drawing.Point(200, 5)
  336. $CustomizeForm.controls.Add($SaveList)
  337. $SaveList.Add_Click( {
  338. $ErrorActionPreference = 'SilentlyContinue'
  339. '$global:WhiteListedApps = @(' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Encoding utf8
  340. @($CustomizeForm.controls) | ForEach {
  341. if ($_ -is [System.Windows.Forms.CheckBox] -and $_.Enabled -and !$_.Checked) {
  342. " ""$( $_.Text )""" | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  343. }
  344. }
  345. ')' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  346. '$global:Bloatware = @(' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  347. @($CustomizeForm.controls) | ForEach {
  348. if ($_ -is [System.Windows.Forms.CheckBox] -and $_.Enabled -and $_.Checked) {
  349. " ""$($_.Text)""" | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  350. }
  351. }
  352. ')' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  353. #Over-ride the white/blacklist with the newly saved custom list
  354. dotInclude custom-lists.ps1
  355. #convert to regular expression to allow for the super-useful -match operator
  356. $global:BloatwareRegex = $global:Bloatware -join '|'
  357. $global:WhiteListedAppsRegex = $global:WhiteListedApps -join '|'
  358. })
  359. Function AddAppToCustomizeForm() {
  360. Param(
  361. [Parameter(Mandatory)]
  362. [int] $position,
  363. [Parameter(Mandatory)]
  364. [string] $appName,
  365. [Parameter(Mandatory)]
  366. [bool] $enabled,
  367. [Parameter(Mandatory)]
  368. [bool] $checked,
  369. [string] $notes
  370. )
  371. $label = New-Object System.Windows.Forms.Label
  372. $label.Location = New-Object System.Drawing.Point(2, (30 + $position * 16))
  373. $label.Text = $notes
  374. $label.Width = 300
  375. $label.Height = 16
  376. $Label.TextAlign = [System.Drawing.ContentAlignment]::TopRight
  377. $CustomizeForm.controls.Add($label)
  378. $Checkbox = New-Object System.Windows.Forms.CheckBox
  379. $Checkbox.Text = $appName
  380. $Checkbox.Location = New-Object System.Drawing.Point(320, (30 + $position * 16))
  381. $Checkbox.Autosize = 1;
  382. $Checkbox.Checked = $checked
  383. $Checkbox.Enabled = $enabled
  384. $CustomizeForm.controls.Add($CheckBox)
  385. }
  386. $Installed = @( (Get-AppxPackage).Name )
  387. $Online = @( (Get-AppxProvisionedPackage -Online).DisplayName )
  388. $AllUsers = @( (Get-AppxPackage -AllUsers).Name )
  389. [int]$checkboxCounter = 0
  390. ForEach ($item in $NonRemovables) {
  391. $string = ""
  392. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) { $string += " ConflictBlacklist " }
  393. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) { $string += " ConflictWhitelist" }
  394. if ( $null -notmatch $Installed -and $Installed -cmatch $item) { $string += "Installed" }
  395. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) { $string += " AllUsers" }
  396. if ( $null -notmatch $Online -and $Online -cmatch $item) { $string += " Online" }
  397. $string += " NONREMOVABLE"
  398. AddAppToCustomizeForm $checkboxCounter $item $false $false $string
  399. ++$checkboxCounter
  400. }
  401. ForEach ( $item in $global:WhiteListedApps ) {
  402. $string = ""
  403. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) { $string += " Conflict NonRemovables " }
  404. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) { $string += " ConflictBlacklist " }
  405. if ( $null -notmatch $Installed -and $Installed -cmatch $item) { $string += "Installed" }
  406. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) { $string += " AllUsers" }
  407. if ( $null -notmatch $Online -and $Online -cmatch $item) { $string += " Online" }
  408. AddAppToCustomizeForm $checkboxCounter $item $true $false $string
  409. ++$checkboxCounter
  410. }
  411. ForEach ( $item in $global:Bloatware ) {
  412. $string = ""
  413. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) { $string += " Conflict NonRemovables " }
  414. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) { $string += " Conflict Whitelist " }
  415. if ( $null -notmatch $Installed -and $Installed -cmatch $item) { $string += "Installed" }
  416. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) { $string += " AllUsers" }
  417. if ( $null -notmatch $Online -and $Online -cmatch $item) { $string += " Online" }
  418. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  419. ++$checkboxCounter
  420. }
  421. ForEach ( $item in $AllUsers ) {
  422. $string = "NEW AllUsers"
  423. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) { continue }
  424. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) { continue }
  425. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) { continue }
  426. if ( $null -notmatch $Installed -and $Installed -cmatch $item) { $string += " Installed" }
  427. if ( $null -notmatch $Online -and $Online -cmatch $item) { $string += " Online" }
  428. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  429. ++$checkboxCounter
  430. }
  431. ForEach ( $item in $Installed ) {
  432. $string = "NEW Installed"
  433. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) { continue }
  434. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) { continue }
  435. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) { continue }
  436. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) { continue }
  437. if ( $null -notmatch $Online -and $Online -cmatch $item) { $string += " Online" }
  438. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  439. ++$checkboxCounter
  440. }
  441. ForEach ( $item in $Online ) {
  442. $string = "NEW Online "
  443. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) { continue }
  444. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) { continue }
  445. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) { continue }
  446. if ( $null -notmatch $Installed -and $Installed -cmatch $item) { continue }
  447. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) { continue }
  448. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  449. ++$checkboxCounter
  450. }
  451. [void]$CustomizeForm.ShowDialog()
  452. })
  453. $RemoveBlacklist.Add_Click( {
  454. $ErrorActionPreference = 'SilentlyContinue'
  455. Function DebloatBlacklist {
  456. Write-Host "Requesting removal of $global:BloatwareRegex"
  457. Write-Host "--- This may take a while - please be patient ---"
  458. Get-AppxPackage | Where-Object Name -cmatch $global:BloatwareRegex | Remove-AppxPackage
  459. Write-Host "...now starting the silent ProvisionedPackage bloatware removal..."
  460. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -cmatch $global:BloatwareRegex | Remove-AppxProvisionedPackage -Online
  461. Write-Host "...and the final cleanup..."
  462. Get-AppxPackage -AllUsers | Where-Object Name -cmatch $global:BloatwareRegex | Remove-AppxPackage
  463. }
  464. Write-Host "`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`nRemoving blacklisted Bloatware.`n"
  465. DebloatBlacklist
  466. Write-Host "Bloatware removed!"
  467. })
  468. $RemoveAllBloatware.Add_Click( {
  469. $ErrorActionPreference = 'SilentlyContinue'
  470. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  471. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  472. #This is the switch parameter for running this script as a 'silent' script, for use in MDT images or any type of mass deployment without user interaction.
  473. Function Begin-SysPrep {
  474. Write-Host "Starting Sysprep Fixes"
  475. # Disable Windows Store Automatic Updates
  476. Write-Host "Adding Registry key to Disable Windows Store Automatic Updates"
  477. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"
  478. If (!(Test-Path $registryPath)) {
  479. Mkdir $registryPath
  480. New-ItemProperty $registryPath AutoDownload -Value 2
  481. }
  482. Set-ItemProperty $registryPath AutoDownload -Value 2
  483. #Stop WindowsStore Installer Service and set to Disabled
  484. Write-Host "Stopping InstallService"
  485. Stop-Service InstallService
  486. Write-Host "Setting InstallService Startup to Disabled"
  487. Set-Service InstallService -StartupType Disabled
  488. }
  489. Function CheckDMWService {
  490. Param([switch]$Debloat)
  491. If (Get-Service dmwappushservice | Where-Object { $_.StartType -eq "Disabled" }) {
  492. Set-Service dmwappushservice -StartupType Automatic
  493. }
  494. If (Get-Service dmwappushservice | Where-Object { $_.Status -eq "Stopped" }) {
  495. Start-Service dmwappushservice
  496. }
  497. }
  498. Function DebloatAll {
  499. #Removes AppxPackages
  500. Get-AppxPackage | Where { !($_.Name -cmatch $global:WhiteListedAppsRegex) -and !($NonRemovables -cmatch $_.Name) } | Remove-AppxPackage
  501. Get-AppxProvisionedPackage -Online | Where { !($_.DisplayName -cmatch $global:WhiteListedAppsRegex) -and !($NonRemovables -cmatch $_.DisplayName) } | Remove-AppxProvisionedPackage -Online
  502. Get-AppxPackage -AllUsers | Where { !($_.Name -cmatch $global:WhiteListedAppsRegex) -and !($NonRemovables -cmatch $_.Name) } | Remove-AppxPackage
  503. }
  504. #Creates a PSDrive to be able to access the 'HKCR' tree
  505. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  506. Function Remove-Keys {
  507. #These are the registry keys that it will delete.
  508. $Keys = @(
  509. #Remove Background Tasks
  510. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  511. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  512. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  513. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  514. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  515. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  516. #Windows File
  517. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  518. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  519. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  520. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  521. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  522. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  523. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  524. #Scheduled Tasks to delete
  525. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  526. #Windows Protocol Keys
  527. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  528. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  529. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  530. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  531. #Windows Share Target
  532. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  533. )
  534. #This writes the output of each key it is removing and also removes the keys listed above.
  535. ForEach ($Key in $Keys) {
  536. Write-Host "Removing $Key from registry"
  537. Remove-Item $Key -Recurse
  538. }
  539. }
  540. Function Protect-Privacy {
  541. #Creates a PSDrive to be able to access the 'HKCR' tree
  542. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  543. #Disables Windows Feedback Experience
  544. Write-Host "Disabling Windows Feedback Experience program"
  545. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  546. If (Test-Path $Advertising) {
  547. Set-ItemProperty $Advertising Enabled -Value 0
  548. }
  549. #Stops Cortana from being used as part of your Windows Search Function
  550. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  551. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  552. If (Test-Path $Search) {
  553. Set-ItemProperty $Search AllowCortana -Value 0
  554. }
  555. #Stops the Windows Feedback Experience from sending anonymous data
  556. Write-Host "Stopping the Windows Feedback Experience program"
  557. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  558. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  559. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  560. If (!(Test-Path $Period3)) {
  561. mkdir $Period1
  562. mkdir $Period2
  563. mkdir $Period3
  564. New-ItemProperty $Period3 PeriodInNanoSeconds -Value 0
  565. }
  566. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  567. #Prevents bloatware applications from returning
  568. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  569. If (!(Test-Path $registryPath)) {
  570. Mkdir $registryPath
  571. New-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  572. }
  573. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  574. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  575. If (Test-Path $Holo) {
  576. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  577. }
  578. #Disables live tiles
  579. Write-Host "Disabling live tiles"
  580. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  581. If (!(Test-Path $Live)) {
  582. mkdir $Live
  583. New-ItemProperty $Live NoTileApplicationNotification -Value 1
  584. }
  585. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  586. Write-Host "Turning off Data Collection"
  587. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  588. If (Test-Path $DataCollection) {
  589. Set-ItemProperty $DataCollection AllowTelemetry -Value 0
  590. }
  591. #Disables People icon on Taskbar
  592. Write-Host "Disabling People icon on Taskbar"
  593. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  594. If (Test-Path $People) {
  595. Set-ItemProperty $People PeopleBand -Value 0
  596. }
  597. #Disables suggestions on start menu
  598. Write-Host "Disabling suggestions on the Start Menu"
  599. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  600. If (Test-Path $Suggestions) {
  601. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 0
  602. }
  603. Write-Host "Removing CloudStore from registry if it exists"
  604. $CloudStore = 'HKCUSoftware\Microsoft\Windows\CurrentVersion\CloudStore'
  605. If (Test-Path $CloudStore) {
  606. Stop-Process Explorer.exe -Force
  607. Remove-Item $CloudStore
  608. Start-Process Explorer.exe -Wait
  609. }
  610. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  611. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  612. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  613. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  614. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  615. reg unload HKU\Default_User
  616. #Disables scheduled tasks that are considered unnecessary
  617. Write-Host "Disabling scheduled tasks"
  618. #Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask
  619. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask
  620. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask
  621. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask
  622. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask
  623. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask
  624. }
  625. Function UnpinStart {
  626. #Credit to Vikingat-Rage
  627. #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
  628. #Unpins all tiles from the Start Menu
  629. Write-Host "Unpinning all tiles from the start menu"
  630. (New-Object -Com Shell.Application).
  631. NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
  632. Items() |
  633. % { $_.Verbs() } |
  634. ? { $_.Name -match 'Un.*pin from Start' } |
  635. % { $_.DoIt() }
  636. }
  637. Function Remove3dObjects {
  638. #Removes 3D Objects from the 'My Computer' submenu in explorer
  639. Write-Output "Removing 3D Objects from explorer 'My Computer' submenu"
  640. $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  641. $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  642. If (Test-Path $Objects32) {
  643. Remove-Item $Objects32 -Recurse
  644. }
  645. If (Test-Path $Objects64) {
  646. Remove-Item $Objects64 -Recurse
  647. }
  648. }
  649. Function CheckDMWService {
  650. Param([switch]$Debloat)
  651. If (Get-Service dmwappushservice | Where-Object { $_.StartType -eq "Disabled" }) {
  652. Set-Service dmwappushservice -StartupType Automatic
  653. }
  654. If (Get-Service dmwappushservice | Where-Object { $_.Status -eq "Stopped" }) {
  655. Start-Service dmwappushservice
  656. }
  657. }
  658. Function CheckInstallService {
  659. If (Get-Service InstallService | Where-Object { $_.Status -eq "Stopped" }) {
  660. Start-Service InstallService
  661. Set-Service InstallService -StartupType Automatic
  662. }
  663. }
  664. Write-Host "Initiating Sysprep"
  665. Begin-SysPrep
  666. Write-Host "Removing bloatware apps."
  667. DebloatAll
  668. Write-Host "Removing leftover bloatware registry keys."
  669. Remove-Keys
  670. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  671. FixWhitelistedApps
  672. Write-Host "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  673. Protect-Privacy
  674. Write-Host "Unpinning tiles from the Start Menu."
  675. UnpinStart
  676. Write-Host "Setting the 'InstallService' Windows service back to 'Started' and the Startup Type 'Automatic'."
  677. CheckDMWService
  678. CheckInstallService
  679. Write-Host "Finished all tasks. `n"
  680. } )
  681. $RevertChange.Add_Click( {
  682. $ErrorActionPreference = 'SilentlyContinue'
  683. #This function will revert the changes you made when running the Start-Debloat function.
  684. #This line reinstalls all of the bloatware that was removed
  685. Get-AppxPackage -AllUsers | ForEach { Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml" }
  686. #Tells Windows to enable your advertising information.
  687. Write-Host "Re-enabling key to show advertisement information"
  688. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  689. If (Test-Path $Advertising) {
  690. Set-ItemProperty $Advertising Enabled -Value 1
  691. }
  692. #Enables Cortana to be used as part of your Windows Search Function
  693. Write-Host "Re-enabling Cortana to be used in your Windows Search"
  694. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  695. If (Test-Path $Search) {
  696. Set-ItemProperty $Search AllowCortana -Value 1
  697. }
  698. #Re-enables the Windows Feedback Experience for sending anonymous data
  699. Write-Host "Re-enabling Windows Feedback Experience"
  700. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  701. If (!(Test-Path $Period)) {
  702. New-Item $Period
  703. }
  704. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  705. #Enables bloatware applications
  706. Write-Host "Adding Registry key to allow bloatware apps to return"
  707. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  708. If (!(Test-Path $registryPath)) {
  709. New-Item $registryPath
  710. }
  711. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  712. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  713. Write-Host "Setting Mixed Reality Portal value to 1"
  714. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  715. If (Test-Path $Holo) {
  716. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  717. }
  718. #Re-enables live tiles
  719. Write-Host "Enabling live tiles"
  720. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  721. If (!(Test-Path $Live)) {
  722. New-Item $Live
  723. }
  724. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  725. #Re-enables data collection
  726. Write-Host "Re-enabling data collection"
  727. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  728. If (!(Test-Path $DataCollection)) {
  729. New-Item $DataCollection
  730. }
  731. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  732. #Re-enables People Icon on Taskbar
  733. Write-Host "Enabling People Icon on Taskbar"
  734. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  735. If (Test-Path $People) {
  736. Set-ItemProperty $People -Name PeopleBand -Value 1 -Verbose
  737. }
  738. #Re-enables suggestions on start menu
  739. Write-Host "Enabling suggestions on the Start Menu"
  740. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  741. If (!(Test-Path $Suggestions)) {
  742. New-Item $Suggestions
  743. }
  744. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  745. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  746. Write-Host "Enabling scheduled tasks that were disabled"
  747. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  748. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  749. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  750. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  751. Get-ScheduledTask DmClient | Enable-ScheduledTask
  752. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  753. Write-Host "Re-enabling and starting WAP Push Service"
  754. #Enable and start WAP Push Service
  755. Set-Service "dmwappushservice" -StartupType Automatic
  756. Start-Service "dmwappushservice"
  757. Write-Host "Re-enabling and starting the Diagnostics Tracking Service"
  758. #Enabling the Diagnostics Tracking Service
  759. Set-Service "DiagTrack" -StartupType Automatic
  760. Start-Service "DiagTrack"
  761. Write-Host "Done reverting changes!"
  762. #
  763. Write-Output "Restoring 3D Objects from Explorer 'My Computer' submenu"
  764. $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  765. $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  766. If (!(Test-Path $Objects32)) {
  767. New-Item $Objects32
  768. }
  769. If (!(Test-Path $Objects64)) {
  770. New-Item $Objects64
  771. }
  772. })
  773. $DisableCortana.Add_Click( {
  774. $ErrorActionPreference = 'SilentlyContinue'
  775. Write-Host "Disabling Cortana"
  776. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  777. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  778. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  779. If (!(Test-Path $Cortana1)) {
  780. New-Item $Cortana1
  781. }
  782. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  783. If (!(Test-Path $Cortana2)) {
  784. New-Item $Cortana2
  785. }
  786. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  787. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  788. If (!(Test-Path $Cortana3)) {
  789. New-Item $Cortana3
  790. }
  791. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  792. Write-Host "Cortana has been disabled."
  793. })
  794. $StopEdgePDFTakeover.Add_Click( {
  795. $ErrorActionPreference = 'SilentlyContinue'
  796. #Stops edge from taking over as the default .PDF viewer
  797. Write-Host "Stopping Edge from taking over as the default .PDF viewer"
  798. $NoPDF = "HKCR:\.pdf"
  799. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  800. $NoWithList = "HKCR:\.pdf\OpenWithList"
  801. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  802. New-ItemProperty $NoPDF NoOpenWith
  803. }
  804. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  805. New-ItemProperty $NoPDF NoStaticDefaultVerb
  806. }
  807. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  808. New-ItemProperty $NoProgids NoOpenWith
  809. }
  810. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  811. New-ItemProperty $NoProgids NoStaticDefaultVerb
  812. }
  813. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  814. New-ItemProperty $NoWithList NoOpenWith
  815. }
  816. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  817. New-ItemProperty $NoWithList NoStaticDefaultVerb
  818. }
  819. #Appends an underscore '_' to the Registry key for Edge
  820. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  821. If (Test-Path $Edge) {
  822. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  823. }
  824. Write-Host "Edge should no longer take over as the default .PDF."
  825. })
  826. $EnableCortana.Add_Click( {
  827. $ErrorActionPreference = 'SilentlyContinue'
  828. Write-Host "Re-enabling Cortana"
  829. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  830. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  831. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  832. If (!(Test-Path $Cortana1)) {
  833. New-Item $Cortana1
  834. }
  835. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  836. If (!(Test-Path $Cortana2)) {
  837. New-Item $Cortana2
  838. }
  839. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  840. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  841. If (!(Test-Path $Cortana3)) {
  842. New-Item $Cortana3
  843. }
  844. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  845. Write-Host "Cortana has been enabled!"
  846. })
  847. $EnableEdgePDFTakeover.Add_Click( {
  848. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  849. $ErrorActionPreference = 'SilentlyContinue'
  850. Write-Host "Setting Edge back to default"
  851. $NoPDF = "HKCR:\.pdf"
  852. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  853. $NoWithList = "HKCR:\.pdf\OpenWithList"
  854. #Sets edge back to default
  855. If (Get-ItemProperty $NoPDF NoOpenWith) {
  856. Remove-ItemProperty $NoPDF NoOpenWith
  857. }
  858. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  859. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  860. }
  861. If (Get-ItemProperty $NoProgids NoOpenWith) {
  862. Remove-ItemProperty $NoProgids NoOpenWith
  863. }
  864. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  865. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  866. }
  867. If (Get-ItemProperty $NoWithList NoOpenWith) {
  868. Remove-ItemProperty $NoWithList NoOpenWith
  869. }
  870. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  871. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  872. }
  873. #Removes an underscore '_' from the Registry key for Edge
  874. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  875. If (Test-Path $Edge2) {
  876. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  877. }
  878. Write-Host "Edge will now be able to be used for .PDF."
  879. })
  880. $DisableTelemetry.Add_Click( {
  881. $ErrorActionPreference = 'SilentlyContinue'
  882. #Disables Windows Feedback Experience
  883. Write-Host "Disabling Windows Feedback Experience program"
  884. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  885. If (Test-Path $Advertising) {
  886. Set-ItemProperty $Advertising Enabled -Value 0
  887. }
  888. #Stops Cortana from being used as part of your Windows Search Function
  889. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  890. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  891. If (Test-Path $Search) {
  892. Set-ItemProperty $Search AllowCortana -Value 0
  893. }
  894. #Disables Web Search in Start Menu
  895. Write-Host "Disabling Bing Search in Start Menu"
  896. $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  897. Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0
  898. If (!(Test-Path $WebSearch)) {
  899. New-Item $WebSearch
  900. }
  901. Set-ItemProperty $WebSearch DisableWebSearch -Value 1
  902. #Stops the Windows Feedback Experience from sending anonymous data
  903. Write-Host "Stopping the Windows Feedback Experience program"
  904. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  905. If (!(Test-Path $Period)) {
  906. New-Item $Period
  907. }
  908. Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
  909. #Prevents bloatware applications from returning and removes Start Menu suggestions
  910. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  911. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  912. $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  913. If (!(Test-Path $registryPath)) {
  914. New-Item $registryPath
  915. }
  916. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  917. If (!(Test-Path $registryOEM)) {
  918. New-Item $registryOEM
  919. }
  920. Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0
  921. Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0
  922. Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0
  923. Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0
  924. Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0
  925. Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0
  926. #Preping mixed Reality Portal for removal
  927. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  928. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  929. If (Test-Path $Holo) {
  930. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  931. }
  932. #Disables Wi-fi Sense
  933. Write-Host "Disabling Wi-Fi Sense"
  934. $WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
  935. $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
  936. $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
  937. If (!(Test-Path $WifiSense1)) {
  938. New-Item $WifiSense1
  939. }
  940. Set-ItemProperty $WifiSense1 Value -Value 0
  941. If (!(Test-Path $WifiSense2)) {
  942. New-Item $WifiSense2
  943. }
  944. Set-ItemProperty $WifiSense2 Value -Value 0
  945. Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
  946. #Disables live tiles
  947. Write-Host "Disabling live tiles"
  948. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  949. If (!(Test-Path $Live)) {
  950. New-Item $Live
  951. }
  952. Set-ItemProperty $Live NoTileApplicationNotification -Value 1
  953. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  954. Write-Host "Turning off Data Collection"
  955. $DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  956. $DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
  957. $DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  958. If (Test-Path $DataCollection1) {
  959. Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
  960. }
  961. If (Test-Path $DataCollection2) {
  962. Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
  963. }
  964. If (Test-Path $DataCollection3) {
  965. Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
  966. }
  967. #Disabling Location Tracking
  968. Write-Host "Disabling Location Tracking"
  969. $SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
  970. $LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
  971. If (!(Test-Path $SensorState)) {
  972. New-Item $SensorState
  973. }
  974. Set-ItemProperty $SensorState SensorPermissionState -Value 0
  975. If (!(Test-Path $LocationConfig)) {
  976. New-Item $LocationConfig
  977. }
  978. Set-ItemProperty $LocationConfig Status -Value 0
  979. #Disables People icon on Taskbar
  980. Write-Host "Disabling People icon on Taskbar"
  981. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  982. If (Test-Path $People) {
  983. Set-ItemProperty $People -Name PeopleBand -Value 0
  984. }
  985. #Disables scheduled tasks that are considered unnecessary
  986. Write-Host "Disabling scheduled tasks"
  987. #Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
  988. Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
  989. Get-ScheduledTask Consolidator | Disable-ScheduledTask
  990. Get-ScheduledTask UsbCeip | Disable-ScheduledTask
  991. Get-ScheduledTask DmClient | Disable-ScheduledTask
  992. Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
  993. #Write-Host "Uninstalling Telemetry Windows Updates"
  994. #Uninstalls Some Windows Updates considered to be Telemetry. !WIP!
  995. #Wusa /Uninstall /KB:3022345 /norestart /quiet
  996. #Wusa /Uninstall /KB:3068708 /norestart /quiet
  997. #Wusa /Uninstall /KB:3075249 /norestart /quiet
  998. #Wusa /Uninstall /KB:3080149 /norestart /quiet
  999. Write-Host "Stopping and disabling WAP Push Service"
  1000. #Stop and disable WAP Push Service
  1001. Stop-Service "dmwappushservice"
  1002. Set-Service "dmwappushservice" -StartupType Disabled
  1003. Write-Host "Stopping and disabling Diagnostics Tracking Service"
  1004. #Disabling the Diagnostics Tracking Service
  1005. Stop-Service "DiagTrack"
  1006. Set-Service "DiagTrack" -StartupType Disabled
  1007. Write-Host "Telemetry has been disabled!"
  1008. })
  1009. $RemoveRegkeys.Add_Click( {
  1010. $ErrorActionPreference = 'SilentlyContinue'
  1011. $Keys = @(
  1012. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  1013. #Remove Background Tasks
  1014. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  1015. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  1016. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  1017. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  1018. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  1019. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  1020. #Windows File
  1021. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  1022. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  1023. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  1024. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  1025. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  1026. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  1027. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  1028. #Scheduled Tasks to delete
  1029. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  1030. #Windows Protocol Keys
  1031. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  1032. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  1033. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  1034. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  1035. #Windows Share Target
  1036. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  1037. )
  1038. #This writes the output of each key it is removing and also removes the keys listed above.
  1039. ForEach ($Key in $Keys) {
  1040. Write-Host "Removing $Key from registry"
  1041. Remove-Item $Key -Recurse
  1042. }
  1043. Write-Host "Additional bloatware keys have been removed!"
  1044. })
  1045. $UnpinStartMenuTiles.Add_Click( {
  1046. #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
  1047. #Unpins all tiles from the Start Menu
  1048. Write-Host "Unpinning all tiles from the start menu"
  1049. (New-Object -Com Shell.Application).
  1050. NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
  1051. Items() |
  1052. % { $_.Verbs() } |
  1053. ? { $_.Name -match 'Un.*pin from Start' } |
  1054. % { $_.DoIt() }
  1055. })
  1056. $RemoveOnedrive.Add_Click( {
  1057. If (Test-Path "$env:USERPROFILE\OneDrive\*") {
  1058. Write-Host "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
  1059. Start-Sleep 1
  1060. If (Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles") {
  1061. Write-Host "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder."
  1062. }
  1063. else {
  1064. If (!(Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles")) {
  1065. 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."
  1066. New-item -Path "$env:USERPROFILE\Desktop" -Name "OneDriveBackupFiles"-ItemType Directory -Force
  1067. Write-Host "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
  1068. }
  1069. }
  1070. Start-Sleep 1
  1071. Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
  1072. Write-Host "Successfully moved all files/folders from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
  1073. Start-Sleep 1
  1074. Write-Host "Proceeding with the removal of OneDrive."
  1075. Start-Sleep 1
  1076. }
  1077. Else {
  1078. 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."
  1079. Start-Sleep 1
  1080. Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
  1081. $OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  1082. If (!(Test-Path $OneDriveKey)) {
  1083. Mkdir $OneDriveKey
  1084. Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
  1085. }
  1086. Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
  1087. }
  1088. Write-Host "Uninstalling OneDrive. Please wait..."
  1089. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  1090. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  1091. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  1092. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  1093. Stop-Process -Name "OneDrive*"
  1094. Start-Sleep 2
  1095. If (!(Test-Path $onedrive)) {
  1096. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  1097. }
  1098. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  1099. Start-Sleep 2
  1100. Write-Host "Stopping explorer"
  1101. Start-Sleep 1
  1102. taskkill.exe /F /IM explorer.exe
  1103. Start-Sleep 3
  1104. Write-Host "Removing leftover files"
  1105. If (Test-Path "$env:USERPROFILE\OneDrive") {
  1106. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  1107. }
  1108. If (Test-Path "$env:LOCALAPPDATA\Microsoft\OneDrive") {
  1109. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  1110. }
  1111. If (Test-Path "$env:PROGRAMDATA\Microsoft OneDrive") {
  1112. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  1113. }
  1114. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  1115. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  1116. }
  1117. Write-Host "Removing OneDrive from windows explorer"
  1118. If (!(Test-Path $ExplorerReg1)) {
  1119. New-Item $ExplorerReg1
  1120. }
  1121. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  1122. If (!(Test-Path $ExplorerReg2)) {
  1123. New-Item $ExplorerReg2
  1124. }
  1125. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  1126. Write-Host "Restarting Explorer that was shut down before."
  1127. Start-Process explorer.exe -NoNewWindow
  1128. Write-Host "OneDrive has been successfully uninstalled!"
  1129. Remove-item env:OneDrive
  1130. })
  1131. $InstallNet35.Add_Click( {
  1132. Write-Host "Initializing the installation of .NET 3.5..."
  1133. DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
  1134. Write-Host ".NET 3.5 has been successfully installed!"
  1135. } )
  1136. $EnableDarkMode.Add_Click( {
  1137. Write-Host "Enabling Dark Mode"
  1138. $Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
  1139. Set-ItemProperty $Theme AppsUseLightTheme -Value 0
  1140. Start-Sleep 1
  1141. Write-Host "Enabled"
  1142. }
  1143. )
  1144. $DisableDarkMode.Add_Click( {
  1145. Write-Host "Disabling Dark Mode"
  1146. $Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
  1147. Set-ItemProperty $Theme AppsUseLightTheme -Value 1
  1148. Start-Sleep 1
  1149. Write-Host "Disabled"
  1150. }
  1151. )
  1152. [void]$Form.ShowDialog()