Windows10DebloaterGUIOLD.ps1 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  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. If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
  3. Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
  4. Start-Sleep 1
  5. Write-Host " 3"
  6. Start-Sleep 1
  7. Write-Host " 2"
  8. Start-Sleep 1
  9. Write-Host " 1"
  10. Start-Sleep 1
  11. Start-Process powershell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
  12. Exit
  13. }
  14. #Unnecessary Windows 10 AppX apps that will be removed by the blacklist.
  15. $global:Bloatware = @(
  16. "Microsoft.BingNews"
  17. "Microsoft.GetHelp"
  18. "Microsoft.Getstarted"
  19. "Microsoft.Messaging"
  20. "Microsoft.Microsoft3DViewer"
  21. "Microsoft.MicrosoftOfficeHub"
  22. "Microsoft.MicrosoftSolitaireCollection"
  23. "Microsoft.NetworkSpeedTest"
  24. "Microsoft.News" # Issue 77
  25. "Microsoft.Office.Lens" # Issue 77
  26. "Microsoft.Office.OneNote"
  27. "Microsoft.Office.Sway"
  28. "Microsoft.OneConnect"
  29. "Microsoft.People"
  30. "Microsoft.Print3D"
  31. "Microsoft.RemoteDesktop" # Issue 120
  32. "Microsoft.SkypeApp"
  33. "Microsoft.StorePurchaseApp"
  34. "Microsoft.Office.Todo.List" # Issue 77
  35. "Microsoft.Whiteboard" # Issue 77
  36. "Microsoft.WindowsAlarms"
  37. "microsoft.windowscommunicationsapps"
  38. "Microsoft.WindowsFeedbackHub"
  39. "Microsoft.WindowsMaps"
  40. "Microsoft.WindowsSoundRecorder"
  41. "Microsoft.Xbox.TCUI"
  42. "Microsoft.XboxApp"
  43. "Microsoft.XboxGameOverlay"
  44. "Microsoft.XboxIdentityProvider"
  45. "Microsoft.XboxSpeechToTextOverlay"
  46. "Microsoft.ZuneMusic"
  47. "Microsoft.ZuneVideo"
  48. #Sponsored Windows 10 AppX Apps
  49. #Add sponsored/featured apps to remove in the "*AppName*" format
  50. "EclipseManager"
  51. "ActiproSoftwareLLC"
  52. "AdobeSystemsIncorporated.AdobePhotoshopExpress"
  53. "Duolingo-LearnLanguagesforFree"
  54. "PandoraMediaInc"
  55. "CandyCrush"
  56. "Wunderlist"
  57. "Flipboard"
  58. "Twitter"
  59. "Facebook"
  60. "Spotify" # Issue 123
  61. "Minecraft"
  62. "Royal Revolt"
  63. "Sway" # Issue 77
  64. "Dolby" # Issue 78
  65. #Optional: Typically not removed but you can if you need to for some reason
  66. #"Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe"
  67. #"Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe"
  68. #"Microsoft.BingWeather"
  69. )
  70. #Valuable Windows 10 AppX apps that most people want to keep. Protected from DeBloat All.
  71. #Credit to /u/GavinEke for a modified version of my whitelist code
  72. $global:WhiteListedApps = @(
  73. "Microsoft.Paint3D"
  74. "Microsoft.WindowsCalculator" # Microsoft removed legacy calculator
  75. "Microsoft.WindowsStore" # Issue 1
  76. "Microsoft.Windows.Photos" # Microsoft disabled/hid legacy photo viewer
  77. "CanonicalGroupLimited.UbuntuonWindows" # Issue 10
  78. "Microsoft.XboxGameCallableUI" # Issue 91
  79. "Microsoft.XboxGamingOverlay" # Issue 25, 91 Many home users want to play games
  80. "Microsoft.Xbox.TCUI" # Issue 25, 91 Many home users want to play games
  81. "Microsoft.XboxIdentityProvider" # Issue 25, 91 Many home users want to play games
  82. "Microsoft.MicrosoftStickyNotes" # Issue 33 New functionality.
  83. "Microsoft.MSPaint" # Issue 32 This is Paint3D, legacy paint still exists in Windows 10
  84. "Microsoft.WindowsCamera" # Issue 65 New functionality.
  85. "\.NET"
  86. "Framework"
  87. "Microsoft.HEIFImageExtension" # Issue 68
  88. "Microsoft.ScreenSketch" # Issue 55: Looks like Microsoft will be axing snipping tool and using Snip & Sketch going forward
  89. "Microsoft.StorePurchaseApp" # Issue 68
  90. "Microsoft.VP9VideoExtensions" # Issue 68
  91. "Microsoft.WebMediaExtensions" # Issue 68
  92. "Microsoft.WebpImageExtension" # Issue 68
  93. "Microsoft.DesktopAppInstaller" # Issue 68
  94. "WindSynthBerry" # Issue 68
  95. "MIDIBerry" # Issue 68
  96. "Slack" # Issue 83
  97. )
  98. #NonRemovable Apps that where getting attempted and the system would reject the uninstall, speeds up debloat and prevents 'initalizing' overlay when removing apps
  99. $NonRemovables = Get-AppxPackage -AllUsers | Where-Object {$_.NonRemovable -eq $true} | foreach{$_.Name}
  100. $NonRemovables += Get-AppxPackage | Where-Object {$_.NonRemovable -eq $true} | foreach{$_.Name}
  101. $NonRemovables += Get-AppxProvisionedPackage -Online | Where-Object {$_.NonRemovable -eq $true} | foreach{$_.DisplayName}
  102. $NonRemovables = $NonRemovables | Sort-Object -unique
  103. if ($NonRemovables -eq $null ) { # the .NonRemovable property doesn't exist until version 18xx. Use a hard-coded list instead.
  104. #WARNING: only use exact names here - no short names or wildcards
  105. $NonRemovables = @(
  106. "1527c705-839a-4832-9118-54d4Bd6a0c89"
  107. "c5e2524a-ea46-4f67-841f-6a9465d9d515"
  108. "E2A4F912-2574-4A75-9BB0-0D023378592B"
  109. "F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE"
  110. "InputApp"
  111. "Microsoft.AAD.BrokerPlugin"
  112. "Microsoft.AccountsControl"
  113. "Microsoft.BioEnrollment"
  114. "Microsoft.CredDialogHost"
  115. "Microsoft.ECApp"
  116. "Microsoft.LockApp"
  117. "Microsoft.MicrosoftEdgeDevToolsClient"
  118. "Microsoft.MicrosoftEdge"
  119. "Microsoft.PPIProjection"
  120. "Microsoft.Win32WebViewHost"
  121. "Microsoft.Windows.Apprep.ChxApp"
  122. "Microsoft.Windows.AssignedAccessLockApp"
  123. "Microsoft.Windows.CapturePicker"
  124. "Microsoft.Windows.CloudExperienceHost"
  125. "Microsoft.Windows.ContentDeliveryManager"
  126. "Microsoft.Windows.Cortana"
  127. "Microsoft.Windows.NarratorQuickStart"
  128. "Microsoft.Windows.ParentalControls"
  129. "Microsoft.Windows.PeopleExperienceHost"
  130. "Microsoft.Windows.PinningConfirmationDialog"
  131. "Microsoft.Windows.SecHealthUI" # Issue 117 Windows Defender
  132. "Microsoft.Windows.SecureAssessmentBrowser"
  133. "Microsoft.Windows.ShellExperienceHost"
  134. "Microsoft.Windows.XGpuEjectDialog"
  135. "Microsoft.XboxGameCallableUI" # Issue 91
  136. "Windows.CBSPreview"
  137. "windows.immersivecontrolpanel"
  138. "Windows.PrintDialog"
  139. "Microsoft.VCLibs.140.00"
  140. "Microsoft.Services.Store.Engagement"
  141. "Microsoft.UI.Xaml.2.0"
  142. )
  143. }
  144. # import library code - located relative to this script
  145. Function dotInclude() {
  146. Param(
  147. [Parameter(Mandatory)]
  148. [string]$includeFile
  149. )
  150. # Look for the file in the same directory as this script
  151. $scriptPath = $PSScriptRoot
  152. if ( $PSScriptRoot -eq $null -and $psISE) {
  153. $scriptPath = (Split-Path -Path $psISE.CurrentFile.FullPath)
  154. }
  155. if ( test-path $scriptPath\$includeFile ){
  156. # import and immediately execute the requested file
  157. . $scriptPath\$includeFile
  158. }
  159. }
  160. # Override built-in blacklist/whitelist with user defined lists
  161. dotInclude 'custom-lists.ps1'
  162. #convert to regular expression to allow for the super-useful -match operator
  163. $global:BloatwareRegex = $global:Bloatware -join '|'
  164. $global:WhiteListedAppsRegex = $global:WhiteListedApps -join '|'
  165. # This form was created using POSHGUI.com a free online gui designer for PowerShell
  166. Add-Type -AssemblyName System.Windows.Forms
  167. [System.Windows.Forms.Application]::EnableVisualStyles()
  168. #region begin GUI
  169. $Form = New-Object system.Windows.Forms.Form
  170. $Form.ClientSize = '408,523'
  171. $Form.text = "Windows10Debloater"
  172. $Form.TopMost = $false
  173. $Debloat = New-Object system.Windows.Forms.Label
  174. $Debloat.text = "Debloat Options"
  175. $Debloat.AutoSize = $true
  176. $Debloat.width = 25
  177. $Debloat.height = 10
  178. $Debloat.location = New-Object System.Drawing.Point(9, 8)
  179. $Debloat.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  180. $CustomizeBlacklists = New-Object system.Windows.Forms.Button
  181. $CustomizeBlacklists.text = "Customize Blacklist"
  182. $CustomizeBlacklists.width = 140
  183. $CustomizeBlacklists.height = 40
  184. $CustomizeBlacklists.location = New-Object System.Drawing.Point(9, 32)
  185. $CustomizeBlacklists.Font = 'Microsoft Sans Serif,10'
  186. $RemoveAllBloatware = New-Object system.Windows.Forms.Button
  187. $RemoveAllBloatware.text = "Remove All Bloatware"
  188. $RemoveAllBloatware.width = 142
  189. $RemoveAllBloatware.height = 40
  190. $RemoveAllBloatware.location = New-Object System.Drawing.Point(8, 79)
  191. $RemoveAllBloatware.Font = 'Microsoft Sans Serif,10'
  192. $RemoveBlacklist = New-Object system.Windows.Forms.Button
  193. $RemoveBlacklist.text = "Remove Bloatware With Blacklist"
  194. $RemoveBlacklist.width = 205
  195. $RemoveBlacklist.height = 37
  196. $RemoveBlacklist.location = New-Object System.Drawing.Point(9, 124)
  197. $RemoveBlacklist.Font = 'Microsoft Sans Serif,10'
  198. $Label1 = New-Object system.Windows.Forms.Label
  199. $Label1.text = "Revert Debloat "
  200. $Label1.AutoSize = $true
  201. $Label1.width = 25
  202. $Label1.height = 10
  203. $Label1.location = New-Object System.Drawing.Point(254, 7)
  204. $Label1.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  205. $RevertChange = New-Object system.Windows.Forms.Button
  206. $RevertChange.text = "Revert Changes"
  207. $RevertChange.width = 113
  208. $RevertChange.height = 36
  209. $RevertChange.location = New-Object System.Drawing.Point(254, 32)
  210. $RevertChange.Font = 'Microsoft Sans Serif,10'
  211. $Label2 = New-Object system.Windows.Forms.Label
  212. $Label2.text = "Optional Changes/Fixes"
  213. $Label2.AutoSize = $true
  214. $Label2.width = 25
  215. $Label2.height = 10
  216. $Label2.location = New-Object System.Drawing.Point(9, 193)
  217. $Label2.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  218. $DisableCortana = New-Object system.Windows.Forms.Button
  219. $DisableCortana.text = "Disable Cortana"
  220. $DisableCortana.width = 111
  221. $DisableCortana.height = 36
  222. $DisableCortana.location = New-Object System.Drawing.Point(9, 217)
  223. $DisableCortana.Font = 'Microsoft Sans Serif,10'
  224. $EnableCortana = New-Object system.Windows.Forms.Button
  225. $EnableCortana.text = "Enable Cortana"
  226. $EnableCortana.width = 112
  227. $EnableCortana.height = 36
  228. $EnableCortana.location = New-Object System.Drawing.Point(9, 260)
  229. $EnableCortana.Font = 'Microsoft Sans Serif,10'
  230. $StopEdgePDFTakeover = New-Object system.Windows.Forms.Button
  231. $StopEdgePDFTakeover.text = "Stop Edge PDF Takeover"
  232. $StopEdgePDFTakeover.width = 175
  233. $StopEdgePDFTakeover.height = 35
  234. $StopEdgePDFTakeover.location = New-Object System.Drawing.Point(130, 217)
  235. $StopEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  236. $EnableEdgePDFTakeover = New-Object system.Windows.Forms.Button
  237. $EnableEdgePDFTakeover.text = "Enable Edge PDF Takeover"
  238. $EnableEdgePDFTakeover.width = 185
  239. $EnableEdgePDFTakeover.height = 35
  240. $EnableEdgePDFTakeover.location = New-Object System.Drawing.Point(130, 260)
  241. $EnableEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  242. $DisableTelemetry = New-Object system.Windows.Forms.Button
  243. $DisableTelemetry.text = "Disable Telemetry/Tasks"
  244. $DisableTelemetry.width = 152
  245. $DisableTelemetry.height = 35
  246. $DisableTelemetry.location = New-Object System.Drawing.Point(9, 345)
  247. $DisableTelemetry.Font = 'Microsoft Sans Serif,10'
  248. $RemoveRegkeys = New-Object system.Windows.Forms.Button
  249. $RemoveRegkeys.text = "Remove Bloatware Regkeys"
  250. $RemoveRegkeys.width = 188
  251. $RemoveRegkeys.height = 35
  252. $RemoveRegkeys.location = New-Object System.Drawing.Point(169, 345)
  253. $RemoveRegkeys.Font = 'Microsoft Sans Serif,10'
  254. $UnpinStartMenuTiles = New-Object system.Windows.Forms.Button
  255. $UnpinStartMenuTiles.text = "Unpin Tiles From Start Menu"
  256. $UnpinStartMenuTiles.width = 190
  257. $UnpinStartMenuTiles.height = 35
  258. $UnpinStartMenuTiles.location = New-Object System.Drawing.Point(169, 303)
  259. $UnpinStartMenuTiles.Font = 'Microsoft Sans Serif,10'
  260. $RemoveOnedrive = New-Object system.Windows.Forms.Button
  261. $RemoveOnedrive.text = "Uninstall OneDrive"
  262. $RemoveOnedrive.width = 152
  263. $RemoveOnedrive.height = 35
  264. $RemoveOnedrive.location = New-Object System.Drawing.Point(9, 303)
  265. $RemoveOnedrive.Font = 'Microsoft Sans Serif,10'
  266. $FixWhitelist = New-Object system.Windows.Forms.Button
  267. $FixWhitelist.text = "Fix Whitelisted Apps"
  268. $FixWhitelist.width = 130
  269. $FixWhitelist.height = 37
  270. $FixWhitelist.location = New-Object System.Drawing.Point(254, 74)
  271. $FixWhitelist.Font = 'Microsoft Sans Serif,10'
  272. $InstallNet35 = New-Object system.Windows.Forms.Button
  273. $InstallNet35.text = "Install .NET v3.5"
  274. $InstallNet35.width = 152
  275. $InstallNet35.height = 39
  276. $InstallNet35.location = New-Object System.Drawing.Point(9, 387)
  277. $InstallNet35.Font = 'Microsoft Sans Serif,10'
  278. $EnableDarkMode = New-Object system.Windows.Forms.Button
  279. $EnableDarkMode.text = "Enable Dark Mode"
  280. $EnableDarkMode.width = 152
  281. $EnableDarkMode.height = 39
  282. $EnableDarkMode.location = New-Object System.Drawing.Point(9, 435)
  283. $EnableDarkMode.Font = 'Microsoft Sans Serif,10'
  284. $DisableDarkMode = New-Object system.Windows.Forms.Button
  285. $DisableDarkMode.text = "Disable Dark Mode"
  286. $DisableDarkMode.width = 152
  287. $DisableDarkMode.height = 39
  288. $DisableDarkMode.location = New-Object System.Drawing.Point(169, 435)
  289. $DisableDarkMode.Font = 'Microsoft Sans Serif,10'
  290. $Form.controls.AddRange(@($Debloat, $CustomizeBlacklists, $RemoveAllBloatware, $RemoveBlacklist, $Label1, $RevertChange, $Label2, $DisableCortana, $EnableCortana, $StopEdgePDFTakeover, $EnableEdgePDFTakeover, $DisableTelemetry, $RemoveRegkeys, $UnpinStartMenuTiles, $RemoveOnedrive, $FixWhitelist, $RemoveBloatNoBlacklist, $InstallNet35, $EnableDarkMode, $DisableDarkMode))
  291. $DebloatFolder = "C:\Temp\Windows10Debloater"
  292. If (Test-Path $DebloatFolder) {
  293. Write-Host "$DebloatFolder exists. Skipping."
  294. }
  295. Else {
  296. Write-Host "The folder "$DebloatFolder" doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
  297. Start-Sleep 1
  298. New-Item -Path "$DebloatFolder" -ItemType Directory
  299. Write-Host "The folder $DebloatFolder was successfully created."
  300. }
  301. Start-Transcript -OutputDirectory "$DebloatFolder"
  302. #region gui events {
  303. $CustomizeBlacklists.Add_Click( {
  304. $CustomizeForm = New-Object system.Windows.Forms.Form
  305. $CustomizeForm.ClientSize = '600,400'
  306. $CustomizeForm.text = "Customize Whitelist and Blacklist"
  307. $CustomizeForm.TopMost = $false
  308. $CustomizeForm.AutoScroll = $true
  309. $SaveList = New-Object system.Windows.Forms.Button
  310. $SaveList.text = "Save custom Whitelist and Blacklist to custom-lists.ps1"
  311. $SaveList.AutoSize = $true
  312. $SaveList.location = New-Object System.Drawing.Point(200, 5)
  313. $CustomizeForm.controls.Add($SaveList)
  314. $SaveList.Add_Click( {
  315. $ErrorActionPreference = 'silentlycontinue'
  316. '$global:WhiteListedApps = @(' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Encoding utf8
  317. @($CustomizeForm.controls) | ForEach {
  318. if ($_ -is [System.Windows.Forms.CheckBox] -and $_.Enabled -and !$_.Checked) {
  319. " ""$( $_.Text )""" | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  320. }
  321. }
  322. ')' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  323. '$global:Bloatware = @(' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  324. @($CustomizeForm.controls) | ForEach {
  325. if ($_ -is [System.Windows.Forms.CheckBox] -and $_.Enabled -and $_.Checked) {
  326. " ""$($_.Text)""" | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  327. }
  328. }
  329. ')' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8
  330. #Over-ride the white/blacklist with the newly saved custom list
  331. dotInclude custom-lists.ps1
  332. #convert to regular expression to allow for the super-useful -match operator
  333. $global:BloatwareRegex = $global:Bloatware -join '|'
  334. $global:WhiteListedAppsRegex = $global:WhiteListedApps -join '|'
  335. })
  336. Function AddAppToCustomizeForm() {
  337. Param(
  338. [Parameter(Mandatory)]
  339. [int] $position,
  340. [Parameter(Mandatory)]
  341. [string] $appName,
  342. [Parameter(Mandatory)]
  343. [bool] $enabled,
  344. [Parameter(Mandatory)]
  345. [bool] $checked,
  346. [string] $notes
  347. )
  348. $label=New-Object system.Windows.Forms.Label
  349. $label.Location = New-Object System.Drawing.Point(2,(30+$position*16))
  350. $label.Text = $notes
  351. $label.width = 300
  352. $label.height= 16
  353. $Label.TextAlign = [System.Drawing.ContentAlignment]::TopRight
  354. $CustomizeForm.controls.Add($label)
  355. $Checkbox = New-Object system.Windows.Forms.CheckBox
  356. $Checkbox.text = $appName
  357. $Checkbox.location = New-Object System.Drawing.Point(320,(30+$position*16))
  358. $Checkbox.Autosize = 1;
  359. $Checkbox.Checked = $checked
  360. $Checkbox.Enabled = $enabled
  361. $CustomizeForm.controls.Add($CheckBox)
  362. }
  363. $Installed = @( (Get-AppxPackage).Name )
  364. $Online = @( (Get-AppxProvisionedPackage -Online).DisplayName )
  365. $AllUsers = @( (Get-AppxPackage -AllUsers).Name )
  366. [int]$checkboxCounter = 0
  367. foreach ($item in $NonRemovables) {
  368. $string = ""
  369. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) {$string += " ConflictBlacklist "}
  370. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) {$string += " ConflictWhitelist" }
  371. if ( $null -notmatch $Installed -and $Installed -cmatch $item){ $string += "Installed"}
  372. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) {$string += " AllUsers"}
  373. if ( $null -notmatch $Online -and $Online -cmatch $item) {$string += " Online"}
  374. $string += " NONREMOVABLE"
  375. AddAppToCustomizeForm $checkboxCounter $item $false $false $string
  376. ++$checkboxCounter
  377. }
  378. foreach ( $item in $global:WhiteListedApps ) {
  379. $string = ""
  380. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) {$string += " Conflict NonRemovables "}
  381. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) {$string += " ConflictBlacklist "}
  382. if ( $null -notmatch $Installed -and $Installed -cmatch $item){ $string += "Installed"}
  383. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) {$string += " AllUsers"}
  384. if ( $null -notmatch $Online -and $Online -cmatch $item) {$string += " Online"}
  385. AddAppToCustomizeForm $checkboxCounter $item $true $false $string
  386. ++$checkboxCounter
  387. }
  388. foreach ( $item in $global:Bloatware ) {
  389. $string = ""
  390. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) {$string += " Conflict NonRemovables "}
  391. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) {$string += " Conflict Whitelist "}
  392. if ( $null -notmatch $Installed -and $Installed -cmatch $item){ $string += "Installed"}
  393. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) {$string += " AllUsers"}
  394. if ( $null -notmatch $Online -and $Online -cmatch $item) {$string += " Online"}
  395. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  396. ++$checkboxCounter
  397. }
  398. foreach ( $item in $AllUsers ) {
  399. $string = "NEW AllUsers"
  400. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) {continue}
  401. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) {continue}
  402. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) {continue}
  403. if ( $null -notmatch $Installed -and $Installed -cmatch $item){ $string += " Installed"}
  404. if ( $null -notmatch $Online -and $Online -cmatch $item) {$string += " Online"}
  405. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  406. ++$checkboxCounter
  407. }
  408. foreach ( $item in $Installed ) {
  409. $string = "NEW Installed"
  410. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) {continue}
  411. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) {continue}
  412. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) {continue}
  413. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) {continue}
  414. if ( $null -notmatch $Online -and $Online -cmatch $item) {$string += " Online"}
  415. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  416. ++$checkboxCounter
  417. }
  418. foreach ( $item in $Online ) {
  419. $string = "NEW Online "
  420. if ( $null -notmatch $NonRemovables -and $NonRemovables -cmatch $item ) {continue}
  421. if ( $null -notmatch $global:WhiteListedAppsRegex -and $item -cmatch $global:WhiteListedAppsRegex ) {continue}
  422. if ( $null -notmatch $global:BloatwareRegex -and $item -cmatch $global:BloatwareRegex ) {continue}
  423. if ( $null -notmatch $Installed -and $Installed -cmatch $item){ continue}
  424. if ( $null -notmatch $AllUsers -and $AllUsers -cmatch $item) { continue}
  425. AddAppToCustomizeForm $checkboxCounter $item $true $true $string
  426. ++$checkboxCounter
  427. }
  428. [void]$CustomizeForm.ShowDialog()
  429. })
  430. $RemoveBlacklist.Add_Click( {
  431. $ErrorActionPreference = 'silentlycontinue'
  432. Function DebloatBlacklist {
  433. foreach ($Bloat in $global:Bloatware) {
  434. Get-AppxPackage -Name $Bloat| Remove-AppxPackage
  435. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online
  436. Write-Host "Requested removal of $Bloat."
  437. }
  438. }
  439. Write-Host "Removing Bloatware with a specific blacklist."
  440. DebloatBlacklist
  441. Write-Host "Bloatware removed!"
  442. })
  443. $RemoveAllBloatware.Add_Click( {
  444. $ErrorActionPreference = 'silentlycontinue'
  445. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  446. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  447. #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.
  448. Function Begin-SysPrep {
  449. Write-Host "Starting Sysprep Fixes"
  450. # Disable Windows Store Automatic Updates
  451. Write-Host "Adding Registry key to Disable Windows Store Automatic Updates"
  452. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"
  453. If (!(Test-Path $registryPath)) {
  454. Mkdir $registryPath
  455. New-ItemProperty $registryPath AutoDownload -Value 2
  456. }
  457. Set-ItemProperty $registryPath AutoDownload -Value 2
  458. #Stop WindowsStore Installer Service and set to Disabled
  459. Write-Host "Stopping InstallService"
  460. Stop-Service InstallService
  461. Write-Host "Setting InstallService Startup to Disabled"
  462. Set-Service InstallService -StartupType Disabled
  463. }
  464. Function CheckDMWService {
  465. Param([switch]$Debloat)
  466. If (Get-Service dmwappushservice | Where-Object {$_.StartType -eq "Disabled"}) {
  467. Set-Service dmwappushservice -StartupType Automatic
  468. }
  469. If (Get-Service dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  470. Start-Service dmwappushservice
  471. }
  472. }
  473. Function DebloatAll {
  474. #Removes AppxPackages
  475. Get-AppxPackage -AllUsers | Where { !($_.Name -cmatch $global:WhiteListedAppsRegex) -and !($NonRemovables -cmatch $_.Name) } | Remove-AppxPackage
  476. Get-AppxPackage | Where { !($_.Name -cmatch $global:WhiteListedAppsRegex) -and !($NonRemovables -cmatch $_.Name) } | Remove-AppxPackage
  477. Get-AppxProvisionedPackage -Online | Where { !($_.Name -cmatch $global:WhiteListedAppsRegex) -and !($NonRemovables -cmatch $_.Name) } | Remove-AppxProvisionedPackage -Online
  478. }
  479. #Creates a PSDrive to be able to access the 'HKCR' tree
  480. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  481. Function Remove-Keys {
  482. #These are the registry keys that it will delete.
  483. $Keys = @(
  484. #Remove Background Tasks
  485. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  486. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  487. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  488. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  489. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  490. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  491. #Windows File
  492. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  493. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  494. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  495. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  496. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  497. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  498. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  499. #Scheduled Tasks to delete
  500. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  501. #Windows Protocol Keys
  502. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  503. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  504. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  505. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  506. #Windows Share Target
  507. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  508. )
  509. #This writes the output of each key it is removing and also removes the keys listed above.
  510. ForEach ($Key in $Keys) {
  511. Write-Host "Removing $Key from registry"
  512. Remove-Item $Key -Recurse
  513. }
  514. }
  515. Function Protect-Privacy {
  516. #Creates a PSDrive to be able to access the 'HKCR' tree
  517. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  518. #Disables Windows Feedback Experience
  519. Write-Host "Disabling Windows Feedback Experience program"
  520. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  521. If (Test-Path $Advertising) {
  522. Set-ItemProperty $Advertising Enabled -Value 0
  523. }
  524. #Stops Cortana from being used as part of your Windows Search Function
  525. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  526. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  527. If (Test-Path $Search) {
  528. Set-ItemProperty $Search AllowCortana -Value 0
  529. }
  530. #Stops the Windows Feedback Experience from sending anonymous data
  531. Write-Host "Stopping the Windows Feedback Experience program"
  532. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  533. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  534. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  535. If (!(Test-Path $Period3)) {
  536. mkdir $Period1
  537. mkdir $Period2
  538. mkdir $Period3
  539. New-ItemProperty $Period3 PeriodInNanoSeconds -Value 0
  540. }
  541. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  542. #Prevents bloatware applications from returning
  543. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  544. If (!(Test-Path $registryPath)) {
  545. Mkdir $registryPath
  546. New-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  547. }
  548. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  549. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  550. If (Test-Path $Holo) {
  551. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  552. }
  553. #Disables live tiles
  554. Write-Host "Disabling live tiles"
  555. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  556. If (!(Test-Path $Live)) {
  557. mkdir $Live
  558. New-ItemProperty $Live NoTileApplicationNotification -Value 1
  559. }
  560. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  561. Write-Host "Turning off Data Collection"
  562. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  563. If (Test-Path $DataCollection) {
  564. Set-ItemProperty $DataCollection AllowTelemetry -Value 0
  565. }
  566. #Disables People icon on Taskbar
  567. Write-Host "Disabling People icon on Taskbar"
  568. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  569. If (Test-Path $People) {
  570. Set-ItemProperty $People PeopleBand -Value 0
  571. }
  572. #Disables suggestions on start menu
  573. Write-Host "Disabling suggestions on the Start Menu"
  574. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  575. If (Test-Path $Suggestions) {
  576. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 0
  577. }
  578. Write-Host "Removing CloudStore from registry if it exists"
  579. $CloudStore = 'HKCUSoftware\Microsoft\Windows\CurrentVersion\CloudStore'
  580. If (Test-Path $CloudStore) {
  581. Stop-Process Explorer.exe -Force
  582. Remove-Item $CloudStore
  583. Start-Process Explorer.exe -Wait
  584. }
  585. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  586. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  587. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  588. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  589. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  590. reg unload HKU\Default_User
  591. #Disables scheduled tasks that are considered unnecessary
  592. Write-Host "Disabling scheduled tasks"
  593. #Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask
  594. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask
  595. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask
  596. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask
  597. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask
  598. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask
  599. }
  600. Function UnpinStart {
  601. #Credit to Vikingat-Rage
  602. #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
  603. #Unpins all tiles from the Start Menu
  604. Write-Host "Unpinning all tiles from the start menu"
  605. (New-Object -Com Shell.Application).
  606. NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
  607. Items() |
  608. %{ $_.Verbs() } |
  609. ?{$_.Name -match 'Un.*pin from Start'} |
  610. %{$_.DoIt()}
  611. }
  612. Function Remove3dObjects {
  613. #Removes 3D Objects from the 'My Computer' submenu in explorer
  614. Write-Output "Removing 3D Objects from explorer 'My Computer' submenu"
  615. $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  616. $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  617. If (Test-Path $Objects32) {
  618. Remove-Item $Objects32 -Recurse
  619. }
  620. If (Test-Path $Objects64) {
  621. Remove-Item $Objects64 -Recurse
  622. }
  623. }
  624. #This includes fixes by xsisbest
  625. Function FixWhitelistedApps {
  626. $ErrorActionPreference = 'silentlycontinue'
  627. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.MSPaint, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.MicrosoftStickyNotes, Microsoft.WindowsSoundRecorder, Microsoft.Windows.Photos)) {
  628. #Credit to abulgatz for the 4 lines of code
  629. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  630. Get-AppxPackage -allusers Microsoft.MSPaint | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  631. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  632. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  633. Get-AppxPackage -allusers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  634. Get-AppxPackage -allusers Microsoft.WindowsSoundRecorder | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  635. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  636. }
  637. }
  638. Function CheckDMWService {
  639. Param([switch]$Debloat)
  640. If (Get-Service dmwappushservice | Where-Object {$_.StartType -eq "Disabled"}) {
  641. Set-Service dmwappushservice -StartupType Automatic
  642. }
  643. If (Get-Service dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  644. Start-Service dmwappushservice
  645. }
  646. }
  647. Function CheckInstallService {
  648. If (Get-Service InstallService | Where-Object {$_.Status -eq "Stopped"}) {
  649. Start-Service InstallService
  650. Set-Service InstallService -StartupType Automatic
  651. }
  652. }
  653. Write-Host "Initiating Sysprep"
  654. Begin-SysPrep
  655. Write-Host "Removing bloatware apps."
  656. DebloatAll
  657. Write-Host "Removing leftover bloatware registry keys."
  658. Remove-Keys
  659. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  660. FixWhitelistedApps
  661. Write-Host "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  662. Protect-Privacy
  663. Write-Host "Unpinning tiles from the Start Menu."
  664. UnpinStart
  665. Write-Host "Setting the 'InstallService' Windows service back to 'Started' and the Startup Type 'Automatic'."
  666. CheckDMWService
  667. CheckInstallService
  668. Write-Host "Finished all tasks. `n"
  669. } )
  670. $RevertChange.Add_Click( {
  671. $ErrorActionPreference = 'silentlycontinue'
  672. #This function will revert the changes you made when running the Start-Debloat function.
  673. #This line reinstalls all of the bloatware that was removed
  674. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  675. #Tells Windows to enable your advertising information.
  676. Write-Host "Re-enabling key to show advertisement information"
  677. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  678. If (Test-Path $Advertising) {
  679. Set-ItemProperty $Advertising Enabled -Value 1
  680. }
  681. #Enables Cortana to be used as part of your Windows Search Function
  682. Write-Host "Re-enabling Cortana to be used in your Windows Search"
  683. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  684. If (Test-Path $Search) {
  685. Set-ItemProperty $Search AllowCortana -Value 1
  686. }
  687. #Re-enables the Windows Feedback Experience for sending anonymous data
  688. Write-Host "Re-enabling Windows Feedback Experience"
  689. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  690. If (!(Test-Path $Period)) {
  691. New-Item $Period
  692. }
  693. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  694. #Enables bloatware applications
  695. Write-Host "Adding Registry key to allow bloatware apps to return"
  696. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  697. If (!(Test-Path $registryPath)) {
  698. New-Item $registryPath
  699. }
  700. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  701. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  702. Write-Host "Setting Mixed Reality Portal value to 1"
  703. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  704. If (Test-Path $Holo) {
  705. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  706. }
  707. #Re-enables live tiles
  708. Write-Host "Enabling live tiles"
  709. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  710. If (!(Test-Path $Live)) {
  711. New-Item $Live
  712. }
  713. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  714. #Re-enables data collection
  715. Write-Host "Re-enabling data collection"
  716. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  717. If (!(Test-Path $DataCollection)) {
  718. New-Item $DataCollection
  719. }
  720. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  721. #Re-enables People Icon on Taskbar
  722. Write-Host "Enabling People Icon on Taskbar"
  723. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  724. If (Test-Path $People) {
  725. Set-ItemProperty $People -Name PeopleBand -Value 1 -Verbose
  726. }
  727. #Re-enables suggestions on start menu
  728. Write-Host "Enabling suggestions on the Start Menu"
  729. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  730. If (!(Test-Path $Suggestions)) {
  731. New-Item $Suggestions
  732. }
  733. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  734. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  735. Write-Host "Enabling scheduled tasks that were disabled"
  736. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  737. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  738. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  739. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  740. Get-ScheduledTask DmClient | Enable-ScheduledTask
  741. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  742. Write-Host "Re-enabling and starting WAP Push Service"
  743. #Enable and start WAP Push Service
  744. Set-Service "dmwappushservice" -StartupType Automatic
  745. Start-Service "dmwappushservice"
  746. Write-Host "Re-enabling and starting the Diagnostics Tracking Service"
  747. #Enabling the Diagnostics Tracking Service
  748. Set-Service "DiagTrack" -StartupType Automatic
  749. Start-Service "DiagTrack"
  750. Write-Host "Done reverting changes!"
  751. #
  752. Write-Output "Restoring 3D Objects from explorer 'My Computer' submenu"
  753. $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  754. $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
  755. If (!(Test-Path $Objects32)) {
  756. New-Item $Objects32
  757. }
  758. If (!(Test-Path $Objects64)) {
  759. New-Item $Objects64
  760. }
  761. })
  762. $FixWhitelist.Add_Click( {
  763. $ErrorActionPreference = 'silentlycontinue'
  764. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos, Microsoft.WindowsCamera)) {
  765. #Credit to abulgatz for these 4 lines of code
  766. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  767. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  768. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  769. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  770. }
  771. Write-Host "Whitelisted apps were either fixed or re-added."
  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. })
  1130. $InstallNet35.Add_Click( {
  1131. Write-Host "Initializing the installation of .NET 3.5..."
  1132. DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
  1133. Write-Host ".NET 3.5 has been successfully installed!"
  1134. } )
  1135. $EnableDarkMode.Add_Click( {
  1136. Write-Host "Enabling Dark Mode"
  1137. $Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
  1138. Set-ItemProperty $Theme AppsUseLightTheme -Value 0
  1139. Start-Sleep 1
  1140. Write-Host "Enabled"
  1141. }
  1142. )
  1143. $DisableDarkMode.Add_Click( {
  1144. Write-Host "Disabling Dark Mode"
  1145. $Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
  1146. Set-ItemProperty $Theme AppsUseLightTheme -Value 1
  1147. Start-Sleep 1
  1148. Write-Host "Disabled"
  1149. }
  1150. )
  1151. [void]$Form.ShowDialog()