Advertisement
Guest User

AppxRemover

a guest
Jun 13th, 2017
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function get_appx_list() {
  2.     $list = Get-AppxPackage
  3.     $result = $list | % {$_.Name} | Sort-Object
  4.  
  5.     return $result
  6. }
  7.  
  8. function get_provisioned_appx_list() {
  9.     $list = Get-AppXProvisionedPackage -Online
  10.     $result = $list | % {$_.PackageName} | Sort-Object
  11.  
  12.     return $result
  13. }
  14.  
  15. function get_appx_fullname($target) {
  16.     $result = Get-AppxPackage ("*" + $target + "*") | % {$_.PackageFullName}
  17.  
  18.     if ($result -eq $null) {
  19.         return $null
  20.     }
  21.  
  22.     if ($result.GetType().BaseType -ne [System.Array]) {
  23.         $result = @($result)
  24.     }
  25.  
  26.     return $result[0]
  27. }
  28.  
  29. function get_provisioned_appx_fullname($target) {
  30.     $list = get_provisioned_appx_list
  31.  
  32.     $result = $null
  33.  
  34.     foreach($item in $list) {
  35.         if ($item.Contains($target)) {
  36.             $result = $item
  37.             break
  38.         }
  39.     }
  40.  
  41.     return $result
  42. }
  43.  
  44. function remove_appx($target_list) {
  45.     $target_list | % {
  46.         $item = get_appx_fullname $_
  47.  
  48.         if ($item -ne $null) {
  49.             Remove-AppxPackage $item
  50.         }
  51.     }
  52. }
  53.  
  54. function remove_provisioned_appx($target_list) {
  55.     $target_list | % {
  56.         $item = get_provisioned_appx_fullname $_
  57.  
  58.         if ($item -ne $null) {
  59.             Write-Host $item
  60.  
  61.             Remove-AppXProvisionedPackage -Online -PackageName $item
  62.         }
  63.     }
  64. }
  65.  
  66. $delete_apps = "A278AB0D.MarchofEmpires", "flaregamesGmbH.RoyalRevolt2", "KeeperSecurityInc.Keeper", "king.com.CandyCrushSodaSaga",
  67.                "Microsoft.3DBuilder", "Microsoft.Getstarted", "Microsoft.Messaging", "Microsoft.Microsoft3DViewer",
  68.                "Microsoft.MicrosoftOfficeHub", "Microsoft.MSPaint", "Microsoft.Office.OneNote", "Microsoft.OneConnect",
  69.                "Microsoft.People", "Microsoft.SkypeApp", "Microsoft.Windows.Photos", "microsoft.windowscommunicationsapps",
  70.                "Microsoft.ZuneMusic", "Microsoft.ZuneVideo", "NAVER.LINEwin8", "ThumbmunkeysLtd.PhototasticCollage"
  71.  
  72. if (($args[0] -eq $null) -Or ($args[0] -eq "")) {
  73.     get_appx_list
  74. } elseif($args[0] -eq "show") {
  75.     get_appx_list
  76. } elseif($args[0] -eq "show-prov") {
  77.     get_provisioned_appx_list
  78. } elseif($args[0] -eq "delete") {
  79.     remove_appx $delete_apps
  80. } elseif($args[0] -eq "delete-prov") {
  81.     remove_provisioned_appx $delete_apps
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement