Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_appx_list() {
- $list = Get-AppxPackage
- $result = $list | % {$_.Name} | Sort-Object
- return $result
- }
- function get_provisioned_appx_list() {
- $list = Get-AppXProvisionedPackage -Online
- $result = $list | % {$_.PackageName} | Sort-Object
- return $result
- }
- function get_appx_fullname($target) {
- $result = Get-AppxPackage ("*" + $target + "*") | % {$_.PackageFullName}
- if ($result -eq $null) {
- return $null
- }
- if ($result.GetType().BaseType -ne [System.Array]) {
- $result = @($result)
- }
- return $result[0]
- }
- function get_provisioned_appx_fullname($target) {
- $list = get_provisioned_appx_list
- $result = $null
- foreach($item in $list) {
- if ($item.Contains($target)) {
- $result = $item
- break
- }
- }
- return $result
- }
- function remove_appx($target_list) {
- $target_list | % {
- $item = get_appx_fullname $_
- if ($item -ne $null) {
- Remove-AppxPackage $item
- }
- }
- }
- function remove_provisioned_appx($target_list) {
- $target_list | % {
- $item = get_provisioned_appx_fullname $_
- if ($item -ne $null) {
- Write-Host $item
- Remove-AppXProvisionedPackage -Online -PackageName $item
- }
- }
- }
- $delete_apps = "A278AB0D.MarchofEmpires", "flaregamesGmbH.RoyalRevolt2", "KeeperSecurityInc.Keeper", "king.com.CandyCrushSodaSaga",
- "Microsoft.3DBuilder", "Microsoft.Getstarted", "Microsoft.Messaging", "Microsoft.Microsoft3DViewer",
- "Microsoft.MicrosoftOfficeHub", "Microsoft.MSPaint", "Microsoft.Office.OneNote", "Microsoft.OneConnect",
- "Microsoft.People", "Microsoft.SkypeApp", "Microsoft.Windows.Photos", "microsoft.windowscommunicationsapps",
- "Microsoft.ZuneMusic", "Microsoft.ZuneVideo", "NAVER.LINEwin8", "ThumbmunkeysLtd.PhototasticCollage"
- if (($args[0] -eq $null) -Or ($args[0] -eq "")) {
- get_appx_list
- } elseif($args[0] -eq "show") {
- get_appx_list
- } elseif($args[0] -eq "show-prov") {
- get_provisioned_appx_list
- } elseif($args[0] -eq "delete") {
- remove_appx $delete_apps
- } elseif($args[0] -eq "delete-prov") {
- remove_provisioned_appx $delete_apps
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement