Here are the scripts that I use to clean up the VM's that I use for testing.
cls
"Junk App Report"
"--------------------Junk---------------"
$Junk = "xbox|phone|disney|skype|spotify|groove|solitaire|zune|mixedreality|tiktok|adobe|prime|soundrecorder|bingweather!3dviewer"
Get-AppxPackage | Where-Object { $_.Name -match $Junk } | Format-Table -Property NonRemovable, Status, Name
Get-AppxPackage -AllUsers | Where-Object { $_.Name -match $Junk } | Format-Table -Property NonRemovable, Status, Name
Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -match $Junk }| Format-Table -Property DisplayName
""
"--------------------Everything---------------"
Get-AppxPackage | Format-Table -Property NonRemovable, Status, Name
Get-AppxPackage -AllUsers | Format-Table -Property NonRemovable, Status, Name
Get-AppxProvisionedPackage -Online | Format-Table -Property DisplayName
Modify the junk variable for that apps that you want to remove. Note that it removes apps that are provisioned but not installed. Start small, do one or 2 apps. The first time you run the script you may get errors because the app hasn't been installed for any user. If you run it a second time it should be clean.
Some apps cannot be removed.
$Junk = "xbox|phone|disney|skype|spotify|groove|solitaire|zune|mixedreality|tiktok|adobe|prime|soundrecorder|bingweather!3dviewer"
"Removing apps for this user only."
$packages = Get-AppxPackage | Where-Object { $_.Name -match $Junk } | Where-Object -Property NonRemovable -eq $false
foreach ($appx in $packages) {
"Removing {0}" -f $appx.name
Remove-AppxPackage $appx
}
""
"Removing apps for all users."
$packages = Get-AppxPackage -AllUsers | Where-Object { $_.Name -match $Junk } | Where-Object -Property NonRemovable -eq $false
foreach ($appx in $packages) {
"Removing {0}" -f $appx.name
Remove-AppxPackage $appx -AllUsers
}
""
"Removing provisioned apps."
$packages = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -match $Junk }
foreach ($appx in $packages) {
"Removing {0}" -f $appx.displayname
Remove-AppxProvisionedPackage -online -allusers -PackageName $appx.PackageName
}