Advertisement
Wasif_Hasan_

UWPAppRemover.ps1

Sep 10th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # UWPAppRemover (c) Wasif Hasan | Aug 2020
  2. $signature1 = @'
  3. public static void ShowConsoleWindow(int state)
  4. {
  5.     var handle = GetConsoleWindow();
  6.     ShowWindow( handle, state );
  7. }
  8. [System.Runtime.InteropServices.DllImport("kernel32.dll")]
  9. static extern IntPtr GetConsoleWindow();
  10. [System.Runtime.InteropServices.DllImport("user32.dll")]
  11. static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  12. '@
  13. $hideconsole = Add-Type -MemberDefinition $signature1 -Name Hide -Namespace HideConsole -ReferencedAssemblies System.Runtime.InteropServices -PassThru
  14. $hideconsole::ShowConsoleWindow(0)
  15. Add-Type -AssemblyName System.Windows.Forms
  16. Add-Type -AssemblyName System.Drawing
  17. $all_uwpapps = "3D Viewer,Advertising,Alarms and Clock,Bing integration,Bubble Witch 3 Saga,Calculator,Calendar,Camera,Feedback Hub,Get Help,Get Started,Groove Music,Mail,Maps,Microsoft News,Microsoft Solitare Collection,Minecraft UWP,Mixed Reality Portal,Movies and TV,Office Online,OneNote Online,Office Lens,Paint 3D,People,Photos,Skype,Snip and Sketch,Sticky Notes,Tips,To Do,Video Editor,Voice Recorder,Weather,Xbox and Game bar,Wallet,Your Phone" -split ","
  18. $def_uwpapps = "3D Viewer,Advertising,Alarms and Clock,Bing integration,Bubble Witch 3 Saga,Calendar,Camera,Feedback Hub,Get Help,Get Started,Groove Music,Maps,Microsoft News,Microsoft Solitare Collection,Minecraft UWP,Mixed Reality Portal,Office Lens,Paint 3D,People,Snip and Sketch,Sticky Notes,Tips,To Do,Video Editor,Voice Recorder,Weather,Xbox and Game bar,Wallet,Your Phone" -split ","
  19. $appx = [ordered]@{"3D Viewer" = "Microsoft.Microsoft3DViewer";  "Advertising" = "Microsoft.Advertising.Xaml*";  "Alarms and Clock" = "Microsoft.WindowsAlarms";  "Bing integration" = "Microsoft.Bing*";  "Bubble Witch 3 Saga" = "king.com.BubbleWitch3Saga";  "Calculator" = "Microsoft.WindowsCalculator";  "Calendar" = "Microsoft.Calendar";  "Camera" = "Microsoft.WindowsCamera";  "Feedback Hub" = "Microsoft.WindowsFeedbackHub";  "Get Help" = "Microsoft.GetHelp";  "Get Started" = "Microsoft.Getstarted";  "Groove Music" = "Microsoft.Zune*";  "Mail" = "Microsoft.Mail";  "Maps" = "Microsoft.WindowsMaps";  "Microsoft News" = "Microsoft.News";  "Microsoft Solitare Collection" = "Microsoft.MicrosoftSolitaireCollection";  "Minecraft UWP" = "Microsoft.MinecraftUWP";  "Mixed Reality Portal" = "Microsoft.MixedReality.Portal";  "Movies and TV" = "Microsoft.MoCamera";  "Office Online" = "Microsoft.MicrosoftOfficeHub";  "OneNote Online" = "Microsoft.Office.OneNote";  "Office Lens" = "Microsoft.Office.Lens";  "Paint 3D" = "Microsoft.MSPaint";  "People" = "Microsoft.People";  "Photos" = "Microsoft.Windows.Photos";  "Skype" = "Microsoft.SkypeApp";  "Snip and Sketch" = "Microsoft.ScreenSketch";  "Sticky Notes" = "Microsoft.MicrosoftStickyNotes";  "Tips" = "Microsoft.HelpAndTips";  "To Do" = "*Todo*";  "Video Editor" = "Microsoft.VP9VideoExtensions";  "Voice Recorder" = "Microsoft.VoiceRecorder";  "Weather" = "*Weather*";  "Xbox and Game bar" = "Microsoft.Xbox*";  "Wallet" = "Microsoft.Wallet";  "Your Phone" = "Microsoft.YourPhone"}
  20. $top=20;$left=50
  21. $f = New-Object System.Windows.Forms.Form
  22. $f.Text = "Select UWP apps to remove"
  23. $f.StartPosition = "CenterScreen"
  24. $f.Size = New-Object System.Drawing.Size(400,850)
  25. $all_uwpapps | Foreach {
  26.   $c = $_.split(" ") -join "_"
  27.   $top += 20
  28.   iex "`$$($c) = New-Object System.Windows.Forms.CheckBox;`$$($c).Top = $($top);`$$($c).Left = $($left);`$$($c).Anchor='Left,Top';`$$($c).Parent='';`$$($c).Text='$($_)';`$$($c).Autosize=`$true;if('$_' -in `$def_uwpapps){`$$c.Checked=`$true};`$f.Controls.Add(`$$c)"
  29. }
  30. $ok=New-Object System.Windows.Forms.Button;$ok.Text='OK';$ok.Top=770;$ok.Left=290
  31. $ok.add_click({$f.Close()});$f.Controls.AddRange($ok)
  32. $sa=New-Object System.Windows.Forms.Button;$sa.Text='Select All';$sa.Top=770;$sa.Left=200
  33. $sa.add_click({$f.Controls | Where-Object {($_.Checked) -or !($_.Checked)} | Foreach {try{$_.Checked=$True}catch{}}});$f.Controls.AddRange($sa)
  34. $null = $f.ShowDialog()
  35. $choices = $f.Controls | Where-Object {$_.Checked} | Select-Object -ExpandProperty Text
  36. $choices | Foreach {Get-AppxPackage $appx."$_" | Select-Object -ExpandProperty Name}
  37. Read-Host
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement