Windows10DebloaterGUI.ps1 63 KB

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