Windows10DebloaterGUI 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. <# This form was created using POSHGUI.com a free online gui designer for PowerShell
  2. .NAME
  3. Untitled
  4. #>
  5. Add-Type -AssemblyName System.Windows.Forms
  6. [System.Windows.Forms.Application]::EnableVisualStyles()
  7. #region begin GUI{
  8. $Form = New-Object system.Windows.Forms.Form
  9. $Form.ClientSize = '408,523'
  10. $Form.text = "Windows10Debloater"
  11. $Form.TopMost = $false
  12. $Debloat = New-Object system.Windows.Forms.Label
  13. $Debloat.text = "Debloat Options"
  14. $Debloat.AutoSize = $true
  15. $Debloat.width = 25
  16. $Debloat.height = 10
  17. $Debloat.location = New-Object System.Drawing.Point(9, 8)
  18. $Debloat.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  19. $RemoveDebloat = New-Object system.Windows.Forms.Button
  20. $RemoveDebloat.text = "Remove All Bloatware"
  21. $RemoveDebloat.width = 142
  22. $RemoveDebloat.height = 40
  23. $RemoveDebloat.location = New-Object System.Drawing.Point(8, 32)
  24. $RemoveDebloat.Font = 'Microsoft Sans Serif,10'
  25. $RemoveBlacklist = New-Object system.Windows.Forms.Button
  26. $RemoveBlacklist.text = "Remove Bloatware With Blacklist"
  27. $RemoveBlacklist.width = 205
  28. $RemoveBlacklist.height = 37
  29. $RemoveBlacklist.location = New-Object System.Drawing.Point(9, 79)
  30. $RemoveBlacklist.Font = 'Microsoft Sans Serif,10'
  31. $Label1 = New-Object system.Windows.Forms.Label
  32. $Label1.text = "Revert Debloat "
  33. $Label1.AutoSize = $true
  34. $Label1.width = 25
  35. $Label1.height = 10
  36. $Label1.location = New-Object System.Drawing.Point(254, 7)
  37. $Label1.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  38. $RevertChange = New-Object system.Windows.Forms.Button
  39. $RevertChange.text = "Revert Changes"
  40. $RevertChange.width = 113
  41. $RevertChange.height = 36
  42. $RevertChange.location = New-Object System.Drawing.Point(254, 32)
  43. $RevertChange.Font = 'Microsoft Sans Serif,10'
  44. $Label2 = New-Object system.Windows.Forms.Label
  45. $Label2.text = "Optional Privacy Changes/Fixes"
  46. $Label2.AutoSize = $true
  47. $Label2.width = 25
  48. $Label2.height = 10
  49. $Label2.location = New-Object System.Drawing.Point(9, 193)
  50. $Label2.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  51. $DisableCortana = New-Object system.Windows.Forms.Button
  52. $DisableCortana.text = "Disable Cortana"
  53. $DisableCortana.width = 111
  54. $DisableCortana.height = 36
  55. $DisableCortana.location = New-Object System.Drawing.Point(9, 217)
  56. $DisableCortana.Font = 'Microsoft Sans Serif,10'
  57. $EnableCortana = New-Object system.Windows.Forms.Button
  58. $EnableCortana.text = "Enable Cortana"
  59. $EnableCortana.width = 112
  60. $EnableCortana.height = 36
  61. $EnableCortana.location = New-Object System.Drawing.Point(9, 260)
  62. $EnableCortana.Font = 'Microsoft Sans Serif,10'
  63. $StopEdgePDFTakeover = New-Object system.Windows.Forms.Button
  64. $StopEdgePDFTakeover.text = "Stop Edge PDF Takeover"
  65. $StopEdgePDFTakeover.width = 161
  66. $StopEdgePDFTakeover.height = 38
  67. $StopEdgePDFTakeover.location = New-Object System.Drawing.Point(130, 217)
  68. $StopEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  69. $EnableEdgePDFTakeover = New-Object system.Windows.Forms.Button
  70. $EnableEdgePDFTakeover.text = "Enable Edge PDF Takeover"
  71. $EnableEdgePDFTakeover.width = 177
  72. $EnableEdgePDFTakeover.height = 39
  73. $EnableEdgePDFTakeover.location = New-Object System.Drawing.Point(130, 260)
  74. $EnableEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  75. $DisableTelemetry = New-Object system.Windows.Forms.Button
  76. $DisableTelemetry.text = "Disable Telemetry/Tasks"
  77. $DisableTelemetry.width = 152
  78. $DisableTelemetry.height = 35
  79. $DisableTelemetry.location = New-Object System.Drawing.Point(9, 303)
  80. $DisableTelemetry.Font = 'Microsoft Sans Serif,10'
  81. $RemoveRegkeys = New-Object system.Windows.Forms.Button
  82. $RemoveRegkeys.text = "Remove Bloatware Regkeys"
  83. $RemoveRegkeys.width = 177
  84. $RemoveRegkeys.height = 40
  85. $RemoveRegkeys.location = New-Object System.Drawing.Point(169, 303)
  86. $RemoveRegkeys.Font = 'Microsoft Sans Serif,10'
  87. $RemoveOnedrive = New-Object system.Windows.Forms.Button
  88. $RemoveOnedrive.text = "Uninstall OneDrive"
  89. $RemoveOnedrive.width = 117
  90. $RemoveOnedrive.height = 35
  91. $RemoveOnedrive.location = New-Object System.Drawing.Point(9, 345)
  92. $RemoveOnedrive.Font = 'Microsoft Sans Serif,10'
  93. $FixWhitelist = New-Object system.Windows.Forms.Button
  94. $FixWhitelist.text = "Fix Whitelisted Apps"
  95. $FixWhitelist.width = 130
  96. $FixWhitelist.height = 37
  97. $FixWhitelist.location = New-Object System.Drawing.Point(254, 74)
  98. $FixWhitelist.Font = 'Microsoft Sans Serif,10'
  99. $RemoveBloatNoBlacklist = New-Object system.Windows.Forms.Button
  100. $RemoveBloatNoBlacklist.text = "Remove Bloatware Without Blacklist"
  101. $RemoveBloatNoBlacklist.width = 223
  102. $RemoveBloatNoBlacklist.height = 39
  103. $RemoveBloatNoBlacklist.location = New-Object System.Drawing.Point(9, 123)
  104. $RemoveBloatNoBlacklist.Font = 'Microsoft Sans Serif,10'
  105. $Form.controls.AddRange(@($Debloat, $RemoveDebloat, $RemoveBlacklist, $Label1, $RevertChange, $Label2, $DisableCortana, $EnableCortana, $StopEdgePDFTakeover, $EnableEdgePDFTakeover, $DisableTelemetry, $RemoveRegkeys, $RemoveOnedrive, $FixWhitelist, $RemoveBloatNoBlacklist))
  106. #region gui events {
  107. $RemoveDebloat.Add_Click( {
  108. $ErrorActionPreference = 'silentlycontinue'
  109. Function DebloatBlacklist {
  110. [CmdletBinding()]
  111. Param ()
  112. $Bloatware = @(
  113. #Unnecessary Windows 10 AppX Apps
  114. "Microsoft.BingNews"
  115. "Microsoft.DesktopAppInstaller"
  116. "Microsoft.GetHelp"
  117. "Microsoft.Getstarted"
  118. "Microsoft.Messaging"
  119. "Microsoft.Microsoft3DViewer"
  120. "Microsoft.MicrosoftOfficeHub"
  121. "Microsoft.MicrosoftSolitaireCollection"
  122. "Microsoft.NetworkSpeedTest"
  123. "Microsoft.Office.OneNote"
  124. "Microsoft.Office.Sway"
  125. "Microsoft.OneConnect"
  126. "Microsoft.People"
  127. "Microsoft.Print3D"
  128. "Microsoft.RemoteDesktop"
  129. "Microsoft.SkypeApp"
  130. "Microsoft.StorePurchaseApp"
  131. "Microsoft.WindowsAlarms"
  132. "Microsoft.WindowsCamera"
  133. "microsoft.windowscommunicationsapps"
  134. "Microsoft.WindowsFeedbackHub"
  135. "Microsoft.WindowsMaps"
  136. "Microsoft.WindowsSoundRecorder"
  137. "Microsoft.Xbox.TCUI"
  138. "Microsoft.XboxApp"
  139. "Microsoft.XboxGameOverlay"
  140. "Microsoft.XboxIdentityProvider"
  141. "Microsoft.XboxSpeechToTextOverlay"
  142. "Microsoft.ZuneMusic"
  143. "Microsoft.ZuneVideo"
  144. #Sponsored Windows 10 AppX Apps
  145. #Add sponsored/featured apps to remove in the "*AppName*" format
  146. "*EclipseManager*"
  147. "*ActiproSoftwareLLC*"
  148. "*AdobeSystemsIncorporated.AdobePhotoshopExpress*"
  149. "*Duolingo-LearnLanguagesforFree*"
  150. "*PandoraMediaInc*"
  151. "*CandyCrush*"
  152. "*Wunderlist*"
  153. "*Flipboard*"
  154. "*Twitter*"
  155. "*Facebook*"
  156. "*Spotify*"
  157. "*Minecraft*"
  158. "*Royal Revolt*"
  159. #Optional: Typically not removed but you can if you need to for some reason
  160. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*"
  161. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*"
  162. #"*Microsoft.BingWeather*"
  163. #"*Microsoft.MSPaint*"
  164. #"*Microsoft.MicrosoftStickyNotes*"
  165. #"*Microsoft.Windows.Photos*"
  166. #"*Microsoft.WindowsCalculator*"
  167. #"*Microsoft.WindowsStore*"
  168. )
  169. foreach ($Bloat in $Bloatware) {
  170. Get-AppxPackage -Name $Bloat| Remove-AppxPackage -ErrorAction SilentlyContinue
  171. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Debloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  172. Write-Output "Trying to remove $Bloat."
  173. }
  174. }
  175. })
  176. $RemoveBlacklist.Add_Click( {
  177. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  178. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  179. #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.
  180. Function Begin-SysPrep {
  181. Write-Verbose -Message ('Starting Sysprep Fixes')
  182. # Disable Windows Store Automatic Updates
  183. Write-Verbose -Message "Adding Registry key to Disable Windows Store Automatic Updates"
  184. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"
  185. If (!(Test-Path $registryPath)) {
  186. Mkdir $registryPath -ErrorAction SilentlyContinue
  187. New-ItemProperty $registryPath -Name AutoDownload -Value 2
  188. }
  189. Else {
  190. Set-ItemProperty $registryPath -Name AutoDownload -Value 2
  191. }
  192. #Stop WindowsStore Installer Service and set to Disabled
  193. Write-Verbose -Message ('Stopping InstallService')
  194. Stop-Service InstallService
  195. Write-Verbose -Message ('Setting InstallService Startup to Disabled')
  196. & Set-Service -Name InstallService -StartupType Disabled
  197. }
  198. Function DebloatAll {
  199. [CmdletBinding()]
  200. Param()
  201. #Removes AppxPackages
  202. #Credit to /u/GavinEke for a modified version of my whitelist code
  203. [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|Microsoft.XboxGameCallableUI|Microsoft.XboxGamingOverlay|Microsoft.Xbox.TCUI|Microsoft.XboxGamingOverlay|Microsoft.XboxIdentityProvider|Microsoft.MicrosoftStickyNotes|Microsoft.MSPaint'
  204. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
  205. Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
  206. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online
  207. }
  208. #Creates a PSDrive to be able to access the 'HKCR' tree
  209. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  210. Function DebloatBlacklist {
  211. $Bloatware = @(
  212. #Unnecessary Windows 10 AppX Apps
  213. "Microsoft.BingNews"
  214. "Microsoft.DesktopAppInstaller"
  215. "Microsoft.GetHelp"
  216. "Microsoft.Getstarted"
  217. "Microsoft.Messaging"
  218. "Microsoft.Microsoft3DViewer"
  219. "Microsoft.MicrosoftOfficeHub"
  220. "Microsoft.MicrosoftSolitaireCollection"
  221. "Microsoft.NetworkSpeedTest"
  222. "Microsoft.Office.OneNote"
  223. "Microsoft.Office.Sway"
  224. "Microsoft.OneConnect"
  225. "Microsoft.People"
  226. "Microsoft.Print3D"
  227. "Microsoft.RemoteDesktop"
  228. "Microsoft.SkypeApp"
  229. "Microsoft.StorePurchaseApp"
  230. "Microsoft.WindowsAlarms"
  231. "Microsoft.WindowsCamera"
  232. "microsoft.windowscommunicationsapps"
  233. "Microsoft.WindowsFeedbackHub"
  234. "Microsoft.WindowsMaps"
  235. "Microsoft.WindowsSoundRecorder"
  236. "Microsoft.Xbox.TCUI"
  237. "Microsoft.XboxApp"
  238. "Microsoft.XboxGameOverlay"
  239. "Microsoft.XboxIdentityProvider"
  240. "Microsoft.XboxSpeechToTextOverlay"
  241. "Microsoft.ZuneMusic"
  242. "Microsoft.ZuneVideo"
  243. #Sponsored Windows 10 AppX Apps
  244. #Add sponsored/featured apps to remove in the "*AppName*" format
  245. "*EclipseManager*"
  246. "*ActiproSoftwareLLC*"
  247. "*AdobeSystemsIncorporated.AdobePhotoshopExpress*"
  248. "*Duolingo-LearnLanguagesforFree*"
  249. "*PandoraMediaInc*"
  250. "*CandyCrush*"
  251. "*Wunderlist*"
  252. "*Flipboard*"
  253. "*Twitter*"
  254. "*Facebook*"
  255. "*Spotify*"
  256. "*Minecraft*"
  257. "*Royal Revolt*"
  258. #Optional: Typically not removed but you can if you need to for some reason
  259. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*"
  260. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*"
  261. #"*Microsoft.BingWeather*"
  262. #"*Microsoft.MSPaint*"
  263. #"*Microsoft.MicrosoftStickyNotes*"
  264. #"*Microsoft.Windows.Photos*"
  265. #"*Microsoft.WindowsCalculator*"
  266. #"*Microsoft.WindowsStore*"
  267. )
  268. foreach ($Bloat in $Bloatware) {
  269. Get-AppxPackage -Name $Bloat| Remove-AppxPackage -ErrorAction SilentlyContinue
  270. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Debloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  271. Write-Output "Trying to remove $Bloat."
  272. }
  273. }
  274. Function Remove-Keys {
  275. #These are the registry keys that it will delete.
  276. $Keys = @(
  277. #Remove Background Tasks
  278. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  279. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  280. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  281. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  282. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  283. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  284. #Windows File
  285. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  286. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  287. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  288. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  289. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  290. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  291. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  292. #Scheduled Tasks to delete
  293. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  294. #Windows Protocol Keys
  295. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  296. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  297. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  298. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  299. #Windows Share Target
  300. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  301. )
  302. #This writes the output of each key it is removing and also removes the keys listed above.
  303. ForEach ($Key in $Keys) {
  304. Write-Output "Removing $Key from registry"
  305. Remove-Item $Key -Recurse -ErrorAction SilentlyContinue
  306. }
  307. }
  308. Function Protect-Privacy {
  309. #Creates a PSDrive to be able to access the 'HKCR' tree
  310. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  311. #Disables Windows Feedback Experience
  312. Write-Output "Disabling Windows Feedback Experience program"
  313. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  314. If (Test-Path $Advertising) {
  315. Set-ItemProperty $Advertising -Name Enabled -Value 0 -Verbose
  316. }
  317. #Stops Cortana from being used as part of your Windows Search Function
  318. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  319. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  320. If (Test-Path $Search) {
  321. Set-ItemProperty $Search -Name AllowCortana -Value 0 -Verbose
  322. }
  323. #Stops the Windows Feedback Experience from sending anonymous data
  324. Write-Output "Stopping the Windows Feedback Experience program"
  325. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  326. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  327. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  328. If (!(Test-Path $Period3)) {
  329. mkdir $Period1 -ErrorAction SilentlyContinue
  330. mkdir $Period2 -ErrorAction SilentlyContinue
  331. mkdir $Period3 -ErrorAction SilentlyContinue
  332. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
  333. }
  334. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  335. #Prevents bloatware applications from returning
  336. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  337. If (!(Test-Path $registryPath)) {
  338. Mkdir $registryPath -ErrorAction SilentlyContinue
  339. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  340. }
  341. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  342. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  343. If (Test-Path $Holo) {
  344. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  345. }
  346. #Disables live tiles
  347. Write-Output "Disabling live tiles"
  348. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  349. If (!(Test-Path $Live)) {
  350. mkdir $Live -ErrorAction SilentlyContinue
  351. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  352. }
  353. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  354. Write-Output "Turning off Data Collection"
  355. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  356. If (Test-Path $DataCollection) {
  357. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  358. }
  359. #Disables People icon on Taskbar
  360. Write-Output "Disabling People icon on Taskbar"
  361. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  362. If (!(Test-Path $People)) {
  363. mkdir $People -ErrorAction SilentlyContinue
  364. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  365. }
  366. #Disables suggestions on start menu
  367. Write-Output "Disabling suggestions on the Start Menu"
  368. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  369. If (Test-Path $Suggestions) {
  370. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
  371. }
  372. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  373. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  374. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  375. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  376. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  377. reg unload HKU\Default_User
  378. #Disables scheduled tasks that are considered unnecessary
  379. Write-Output "Disabling scheduled tasks"
  380. #Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask -ErrorAction SilentlyContinue
  381. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask -ErrorAction SilentlyContinue
  382. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask -ErrorAction SilentlyContinue
  383. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask -ErrorAction SilentlyContinue
  384. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask -ErrorAction SilentlyContinue
  385. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask -ErrorAction SilentlyContinue
  386. }
  387. #This includes fixes by xsisbest
  388. Function FixWhitelistedApps {
  389. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.MSPaint, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.MicrosoftStickyNotes, Microsoft.WindowsSoundRecorder, Microsoft.Windows.Photos)) {
  390. #Credit to abulgatz for the 4 lines of code
  391. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  392. Get-AppxPackage -allusers Microsoft.MSPaint | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  393. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  394. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  395. Get-AppxPackage -allusers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  396. Get-AppxPackage -allusers Microsoft.WindowsSoundRecorder | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  397. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  398. }
  399. }
  400. Function CheckService {
  401. If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  402. Start-Service -Name dmwappushservice
  403. }
  404. }
  405. Write-Output "Initiating Sysprep"
  406. Begin-SysPrep
  407. Write-Output "Removing bloatware apps."
  408. DebloatAll
  409. DebloatBlacklist
  410. Write-Output "Removing leftover bloatware registry keys."
  411. Remove-Keys
  412. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  413. FixWhitelistedApps
  414. Write-Output "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  415. Protect-Privacy
  416. #Write-Output "Stopping Edge from taking over as the default PDF Viewer."
  417. #Stop-EdgePDF
  418. Write-Output "Finished all tasks."
  419. })
  420. $RemoveBloatNoBlacklist.Add_Click( {
  421. $ErrorActionPreference = 'silentlycontinue'
  422. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  423. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  424. #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.
  425. param (
  426. [switch]$Debloat, [switch]$SysPrep
  427. )
  428. Function Begin-SysPrep {
  429. param([switch]$SysPrep)
  430. Write-Verbose -Message ('Starting Sysprep Fixes')
  431. # Disable Windows Store Automatic Updates
  432. Write-Verbose -Message "Adding Registry key to Disable Windows Store Automatic Updates"
  433. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"
  434. If (!(Test-Path $registryPath)) {
  435. Mkdir $registryPath -ErrorAction SilentlyContinue
  436. New-ItemProperty $registryPath -Name AutoDownload -Value 2
  437. }
  438. Else {
  439. Set-ItemProperty $registryPath -Name AutoDownload -Value 2
  440. }
  441. #Stop WindowsStore Installer Service and set to Disabled
  442. Write-Verbose -Message ('Stopping InstallService')
  443. Stop-Service InstallService
  444. Write-Verbose -Message ('Setting InstallService Startup to Disabled')
  445. & Set-Service -Name InstallService -StartupType Disabled
  446. }
  447. #Creates a PSDrive to be able to access the 'HKCR' tree
  448. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  449. Function Start-Debloat {
  450. param([switch]$Debloat)
  451. #Removes AppxPackages
  452. #Credit to Reddit user /u/GavinEke for a modified version of my whitelist code
  453. [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.MSPaint|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.MicrosoftStickyNotes|Microsoft.WindowsSoundRecorder|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows'
  454. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue
  455. # Run this again to avoid error on 1803 or having to reboot.
  456. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue
  457. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  458. }
  459. Function Remove-Keys {
  460. Param([switch]$Debloat)
  461. #These are the registry keys that it will delete.
  462. $Keys = @(
  463. #Remove Background Tasks
  464. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  465. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  466. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  467. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  468. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  469. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  470. #Windows File
  471. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  472. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  473. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  474. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  475. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  476. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  477. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  478. #Scheduled Tasks to delete
  479. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  480. #Windows Protocol Keys
  481. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  482. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  483. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  484. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  485. #Windows Share Target
  486. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  487. )
  488. #This writes the output of each key it is removing and also removes the keys listed above.
  489. ForEach ($Key in $Keys) {
  490. Write-Output "Removing $Key from registry"
  491. Remove-Item $Key -Recurse -ErrorAction SilentlyContinue
  492. }
  493. }
  494. Function Protect-Privacy {
  495. Param([switch]$Debloat)
  496. #Creates a PSDrive to be able to access the 'HKCR' tree
  497. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  498. #Disables Windows Feedback Experience
  499. Write-Output "Disabling Windows Feedback Experience program"
  500. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  501. If (Test-Path $Advertising) {
  502. Set-ItemProperty $Advertising -Name Enabled -Value 0 -Verbose
  503. }
  504. #Stops Cortana from being used as part of your Windows Search Function
  505. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  506. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  507. If (Test-Path $Search) {
  508. Set-ItemProperty $Search -Name AllowCortana -Value 0 -Verbose
  509. }
  510. #Stops the Windows Feedback Experience from sending anonymous data
  511. Write-Output "Stopping the Windows Feedback Experience program"
  512. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  513. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  514. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  515. If (!(Test-Path $Period3)) {
  516. mkdir $Period1 -ErrorAction SilentlyContinue
  517. mkdir $Period2 -ErrorAction SilentlyContinue
  518. mkdir $Period3 -ErrorAction SilentlyContinue
  519. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
  520. }
  521. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  522. #Prevents bloatware applications from returning
  523. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  524. If (!(Test-Path $registryPath)) {
  525. Mkdir $registryPath -ErrorAction SilentlyContinue
  526. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  527. }
  528. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  529. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  530. If (Test-Path $Holo) {
  531. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  532. }
  533. #Disables live tiles
  534. Write-Output "Disabling live tiles"
  535. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  536. If (!(Test-Path $Live)) {
  537. mkdir $Live -ErrorAction SilentlyContinue
  538. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  539. }
  540. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  541. Write-Output "Turning off Data Collection"
  542. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  543. If (Test-Path $DataCollection) {
  544. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  545. }
  546. #Disables People icon on Taskbar
  547. Write-Output "Disabling People icon on Taskbar"
  548. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  549. If (!(Test-Path $People)) {
  550. mkdir $People -ErrorAction SilentlyContinue
  551. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  552. }
  553. #Disables suggestions on start menu
  554. Write-Output "Disabling suggestions on the Start Menu"
  555. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  556. If (Test-Path $Suggestions) {
  557. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
  558. }
  559. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  560. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  561. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  562. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  563. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  564. reg unload HKU\Default_User
  565. #Disables scheduled tasks that are considered unnecessary
  566. Write-Output "Disabling scheduled tasks"
  567. #Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask -ErrorAction SilentlyContinue
  568. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask -ErrorAction SilentlyContinue
  569. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask -ErrorAction SilentlyContinue
  570. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask -ErrorAction SilentlyContinue
  571. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask -ErrorAction SilentlyContinue
  572. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask -ErrorAction SilentlyContinue
  573. }
  574. #This includes fixes by xsisbest
  575. Function FixWhitelistedApps {
  576. Param([switch]$Debloat)
  577. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.MSPaint, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.MicrosoftStickyNotes, Microsoft.WindowsSoundRecorder, Microsoft.Windows.Photos)) {
  578. #Credit to abulgatz for the 4 lines of code
  579. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  580. Get-AppxPackage -allusers Microsoft.MSPaint | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  581. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  582. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  583. Get-AppxPackage -allusers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  584. Get-AppxPackage -allusers Microsoft.WindowsSoundRecorder | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  585. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  586. }
  587. }
  588. Function CheckService {
  589. Param([switch]$Debloat)
  590. If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  591. Start-Service -Name dmwappushservice
  592. }
  593. }
  594. Begin-SysPrep
  595. Write-Output "Removing bloatware apps."
  596. Start-Debloat
  597. Write-Output "Removing leftover bloatware registry keys."
  598. Remove-Keys
  599. Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  600. FixWhitelistedApps
  601. Write-Output "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  602. Protect-Privacy
  603. #Write-Output "Stopping Edge from taking over as the default PDF Viewer."
  604. Write-Output "Checking to make sure that the service 'dmwappushservice' has been started."
  605. CheckService
  606. Write-Output "Finished all tasks."
  607. })
  608. $RevertChange.Add_Click( {
  609. $ErrorActionPreference = 'silentlycontinue'
  610. #This function will revert the changes you made when running the Start-Debloat function.
  611. #This line reinstalls all of the bloatware that was removed
  612. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  613. #Tells Windows to enable your advertising information.
  614. Write-Output "Re-enabling key to show advertisement information"
  615. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  616. If (Test-Path $Advertising) {
  617. Set-ItemProperty $Advertising Enabled -Value 1
  618. }
  619. #Enables Cortana to be used as part of your Windows Search Function
  620. Write-Output "Re-enabling Cortana to be used in your Windows Search"
  621. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  622. If (Test-Path $Search) {
  623. Set-ItemProperty $Search AllowCortana -Value 1
  624. }
  625. #Re-enables the Windows Feedback Experience for sending anonymous data
  626. Write-Output "Re-enabling Windows Feedback Experience"
  627. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  628. If (!(Test-Path $Period)) {
  629. New-Item $Period
  630. }
  631. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  632. #Enables bloatware applications
  633. Write-Output "Adding Registry key to allow bloatware apps to return"
  634. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  635. If (!(Test-Path $registryPath)) {
  636. New-Item $registryPath
  637. }
  638. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  639. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  640. Write-Output "Setting Mixed Reality Portal value to 1"
  641. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  642. If (Test-Path $Holo) {
  643. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  644. }
  645. #Re-enables live tiles
  646. Write-Output "Enabling live tiles"
  647. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  648. If (!(Test-Path $Live)) {
  649. New-Item $Live
  650. }
  651. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  652. #Re-enables data collection
  653. Write-Output "Re-enabling data collection"
  654. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  655. If (!(Test-Path $DataCollection)) {
  656. New-Item $DataCollection
  657. }
  658. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  659. #Re-enables People Icon on Taskbar
  660. Write-Output "Enabling People icon on Taskbar"
  661. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  662. If (!(Test-Path $People)) {
  663. New-Item $People
  664. }
  665. Set-ItemProperty $People PeopleBand -Value 1
  666. #Re-enables suggestions on start menu
  667. Write-Output "Enabling suggestions on the Start Menu"
  668. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  669. If (!(Test-Path $Suggestions)) {
  670. New-Item $Suggestions
  671. }
  672. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  673. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  674. Write-Output "Enabling scheduled tasks that were disabled"
  675. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  676. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  677. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  678. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  679. Get-ScheduledTask DmClient | Enable-ScheduledTask
  680. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  681. Write-Output "Re-enabling and starting WAP Push Service"
  682. #Enable and start WAP Push Service
  683. Set-Service "dmwappushservice" -StartupType Automatic
  684. Start-Service "dmwappushservice"
  685. Write-Output "Re-enabling and starting the Diagnostics Tracking Service"
  686. #Enabling the Diagnostics Tracking Service
  687. Set-Service "DiagTrack" -StartupType Automatic
  688. Start-Service "DiagTrack"
  689. })
  690. $FixWhitelist.Add_Click( {
  691. $ErrorActionPreference = 'silentlycontinue'
  692. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  693. #Credit to abulgatz for these 4 lines of code
  694. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  695. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  696. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  697. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  698. }
  699. })
  700. $DisableCortana.Add_Click( {
  701. $ErrorActionPreference = 'silentlycontinue'
  702. Write-Host "Disabling Cortana"
  703. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  704. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  705. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  706. If (!(Test-Path $Cortana1)) {
  707. New-Item $Cortana1
  708. }
  709. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  710. If (!(Test-Path $Cortana2)) {
  711. New-Item $Cortana2
  712. }
  713. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  714. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  715. If (!(Test-Path $Cortana3)) {
  716. New-Item $Cortana3
  717. }
  718. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  719. })
  720. $StopEdgePDFTakeover.Add_Click( {
  721. #Stops edge from taking over as the default .PDF viewer
  722. Write-Output "Stopping Edge from taking over as the default .PDF viewer"
  723. $NoPDF = "HKCR:\.pdf"
  724. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  725. $NoWithList = "HKCR:\.pdf\OpenWithList"
  726. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  727. New-ItemProperty $NoPDF NoOpenWith
  728. }
  729. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  730. New-ItemProperty $NoPDF NoStaticDefaultVerb
  731. }
  732. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  733. New-ItemProperty $NoProgids NoOpenWith
  734. }
  735. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  736. New-ItemProperty $NoProgids NoStaticDefaultVerb
  737. }
  738. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  739. New-ItemProperty $NoWithList NoOpenWith
  740. }
  741. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  742. New-ItemProperty $NoWithList NoStaticDefaultVerb
  743. }
  744. #Appends an underscore '_' to the Registry key for Edge
  745. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  746. If (Test-Path $Edge) {
  747. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  748. }
  749. })
  750. $EnableCortana.Add_Click( {
  751. $ErrorActionPreference = 'silentlycontinue'
  752. Write-Host "Re-enabling Cortana"
  753. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  754. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  755. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  756. If (!(Test-Path $Cortana1)) {
  757. New-Item $Cortana1
  758. }
  759. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  760. If (!(Test-Path $Cortana2)) {
  761. New-Item $Cortana2
  762. }
  763. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  764. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  765. If (!(Test-Path $Cortana3)) {
  766. New-Item $Cortana3
  767. }
  768. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  769. })
  770. $EnableEdgePDFTakeover.Add_Click( {
  771. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  772. $ErrorActionPreference = 'silentlycontinue'
  773. Write-Output "Setting Edge back to default"
  774. $NoPDF = "HKCR:\.pdf"
  775. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  776. $NoWithList = "HKCR:\.pdf\OpenWithList"
  777. #Sets edge back to default
  778. If (Get-ItemProperty $NoPDF NoOpenWith) {
  779. Remove-ItemProperty $NoPDF NoOpenWith
  780. }
  781. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  782. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  783. }
  784. If (Get-ItemProperty $NoProgids NoOpenWith) {
  785. Remove-ItemProperty $NoProgids NoOpenWith
  786. }
  787. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  788. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  789. }
  790. If (Get-ItemProperty $NoWithList NoOpenWith) {
  791. Remove-ItemProperty $NoWithList NoOpenWith
  792. }
  793. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  794. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  795. }
  796. #Removes an underscore '_' from the Registry key for Edge
  797. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  798. If (Test-Path $Edge2) {
  799. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  800. }
  801. })
  802. $DisableTelemetry.Add_Click( {
  803. $ErrorActionPreference = 'silentlycontinue'
  804. #Disables Windows Feedback Experience
  805. Write-Output "Disabling Windows Feedback Experience program"
  806. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  807. If (Test-Path $Advertising) {
  808. Set-ItemProperty $Advertising Enabled -Value 0
  809. }
  810. #Stops Cortana from being used as part of your Windows Search Function
  811. Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
  812. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  813. If (Test-Path $Search) {
  814. Set-ItemProperty $Search AllowCortana -Value 0
  815. }
  816. #Disables Web Search in Start Menu
  817. Write-Output "Disabling Bing Search in Start Menu"
  818. $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  819. Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0
  820. If (!(Test-Path $WebSearch)) {
  821. New-Item $WebSearch
  822. }
  823. Set-ItemProperty $WebSearch DisableWebSearch -Value 1
  824. #Stops the Windows Feedback Experience from sending anonymous data
  825. Write-Output "Stopping the Windows Feedback Experience program"
  826. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  827. If (!(Test-Path $Period)) {
  828. New-Item $Period
  829. }
  830. Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
  831. #Prevents bloatware applications from returning and removes Start Menu suggestions
  832. Write-Output "Adding Registry key to prevent bloatware apps from returning"
  833. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  834. $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  835. If (!(Test-Path $registryPath)) {
  836. New-Item $registryPath
  837. }
  838. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  839. If (!(Test-Path $registryOEM)) {
  840. New-Item $registryOEM
  841. }
  842. Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0
  843. Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0
  844. Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0
  845. Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0
  846. Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0
  847. Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0
  848. #Preping mixed Reality Portal for removal
  849. Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  850. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  851. If (Test-Path $Holo) {
  852. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  853. }
  854. #Disables Wi-fi Sense
  855. Write-Output "Disabling Wi-Fi Sense"
  856. $WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
  857. $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
  858. $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
  859. If (!(Test-Path $WifiSense1)) {
  860. New-Item $WifiSense1
  861. }
  862. Set-ItemProperty $WifiSense1 Value -Value 0
  863. If (!(Test-Path $WifiSense2)) {
  864. New-Item $WifiSense2
  865. }
  866. Set-ItemProperty $WifiSense2 Value -Value 0
  867. Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
  868. #Disables live tiles
  869. Write-Output "Disabling live tiles"
  870. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  871. If (!(Test-Path $Live)) {
  872. New-Item $Live
  873. }
  874. Set-ItemProperty $Live NoTileApplicationNotification -Value 1
  875. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  876. Write-Output "Turning off Data Collection"
  877. $DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  878. $DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
  879. $DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  880. If (Test-Path $DataCollection1) {
  881. Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
  882. }
  883. If (Test-Path $DataCollection2) {
  884. Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
  885. }
  886. If (Test-Path $DataCollection3) {
  887. Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
  888. }
  889. #Disabling Location Tracking
  890. Write-Output "Disabling Location Tracking"
  891. $SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
  892. $LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
  893. If (!(Test-Path $SensorState)) {
  894. New-Item $SensorState
  895. }
  896. Set-ItemProperty $SensorState SensorPermissionState -Value 0
  897. If (!(Test-Path $LocationConfig)) {
  898. New-Item $LocationConfig
  899. }
  900. Set-ItemProperty $LocationConfig Status -Value 0
  901. #Disables People icon on Taskbar
  902. Write-Output "Disabling People icon on Taskbar"
  903. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  904. If (!(Test-Path $People)) {
  905. New-Item $People
  906. }
  907. Set-ItemProperty $People PeopleBand -Value 0
  908. #Disables scheduled tasks that are considered unnecessary
  909. Write-Output "Disabling scheduled tasks"
  910. Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
  911. Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
  912. Get-ScheduledTask Consolidator | Disable-ScheduledTask
  913. Get-ScheduledTask UsbCeip | Disable-ScheduledTask
  914. Get-ScheduledTask DmClient | Disable-ScheduledTask
  915. Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
  916. Write-Output "Stopping and disabling WAP Push Service"
  917. #Stop and disable WAP Push Service
  918. Stop-Service "dmwappushservice"
  919. Set-Service "dmwappushservice" -StartupType Disabled
  920. Write-Output "Stopping and disabling Diagnostics Tracking Service"
  921. #Disabling the Diagnostics Tracking Service
  922. Stop-Service "DiagTrack"
  923. Set-Service "DiagTrack" -StartupType Disabled
  924. })
  925. $RemoveRegkeys.Add_Click( {
  926. $ErrorActionPreference = 'silentlycontinue'
  927. $Keys = @(
  928. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  929. #Remove Background Tasks
  930. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  931. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  932. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  933. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  934. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  935. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  936. #Windows File
  937. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  938. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  939. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  940. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  941. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  942. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  943. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  944. #Scheduled Tasks to delete
  945. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  946. #Windows Protocol Keys
  947. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  948. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  949. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  950. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  951. #Windows Share Target
  952. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  953. )
  954. #This writes the output of each key it is removing and also removes the keys listed above.
  955. ForEach ($Key in $Keys) {
  956. Write-Output "Removing $Key from registry"
  957. Remove-Item $Key -Recurse
  958. }
  959. })
  960. $RemoveOnedrive.Add_Click( {
  961. Write-Output "Uninstalling OneDrive"
  962. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  963. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  964. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  965. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  966. Stop-Process -Name "OneDrive*"
  967. Start-Sleep 2
  968. If (!(Test-Path $onedrive)) {
  969. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  970. }
  971. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  972. Start-Sleep 2
  973. Write-Output "Stopping explorer"
  974. Start-Sleep 1
  975. .\taskkill.exe /F /IM explorer.exe
  976. Start-Sleep 3
  977. Write-Output "Removing leftover files"
  978. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  979. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  980. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  981. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  982. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  983. }
  984. Write-Output "Removing OneDrive from windows explorer"
  985. If (!(Test-Path $ExplorerReg1)) {
  986. New-Item $ExplorerReg1
  987. }
  988. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  989. If (!(Test-Path $ExplorerReg2)) {
  990. New-Item $ExplorerReg2
  991. }
  992. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  993. Write-Output "Restarting Explorer that was shut down before."
  994. Start-Process explorer.exe -NoNewWindow
  995. })
  996. #endregion events }
  997. #endregion GUI }
  998. #Write your logic code here
  999. [void]$Form.ShowDialog()