New
#11
Well, you shouldn't have to delete from WindowsApps as the Remove-AppxProvisionedPackage command does that (at least for me in 14393 build ).
If it isn't (and I remember sometime in the past it wasn't) and you want to do it manually it would be like this...
Note that you can delete from %appdata% easily enough as your user owns it. You don't have authority to WindowsApps so you need to take ownership and grant yourself authority first or the Remove-Item will fail. This means you can't just duplicate the last 2 lines and stick them at the end of the foreach loop.
See below in red. I've also updated the list of apps from GitHub - W4RH4WK as there are more these days. This script was taken from that project in the first place.
I've not tried this updated code as I've already uninstalled all my apps and the directories in WindowsApps were removed automatically for me. Let us know if it works OK or not...Code:$apps = @( # default Windows 10 apps "Microsoft.3DBuilder" "Microsoft.Appconnector" "Microsoft.BingFinance" "Microsoft.BingNews" "Microsoft.BingSports" "Microsoft.BingWeather" #"Microsoft.FreshPaint" "Microsoft.Getstarted" "Microsoft.MicrosoftOfficeHub" "Microsoft.MicrosoftSolitaireCollection" #"Microsoft.MicrosoftStickyNotes" "Microsoft.Office.OneNote" #"Microsoft.OneConnect" "Microsoft.People" "Microsoft.SkypeApp" #"Microsoft.Windows.Photos" "Microsoft.WindowsAlarms" #"Microsoft.WindowsCalculator" "Microsoft.WindowsCamera" "Microsoft.WindowsMaps" "Microsoft.WindowsPhone" "Microsoft.WindowsSoundRecorder" #"Microsoft.WindowsStore" "Microsoft.XboxApp" "Microsoft.ZuneMusic" "Microsoft.ZuneVideo" "microsoft.windowscommunicationsapps" "Microsoft.MinecraftUWP" # Threshold 2 apps "Microsoft.CommsPhone" "Microsoft.ConnectivityStore" "Microsoft.Messaging" "Microsoft.Office.Sway" # non-Microsoft "9E2F88E3.Twitter" "Flipboard.Flipboard" "ShazamEntertainmentLtd.Shazam" "king.com.CandyCrushSaga" "king.com.CandyCrushSodaSaga" "king.com.*" "ClearChannelRadioDigital.iHeartRadio" #"TheNewYorkTimes.NYTCrossword" ) foreach ($app in $apps) { Write-Host "Removing " -noNewLine; Write-Host $app -f white # Need to hide the progress bar as otherwise it remains on the screen $ProgressPreference = "SilentlyContinue" Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage $ProgressPreference = "Continue" Get-AppXProvisionedPackage -Online | where DisplayName -EQ $app | Remove-AppxProvisionedPackage -Online $appPath="$Env:LOCALAPPDATA\Packages\$app*" Remove-Item $appPath -Recurse -Force -ErrorAction 0 $appPath = "$apppath = "C:\Program Files\WindowsApps\$app*" # take ownership takeown /f "$appPath" /r # Grant full rights to current user icacls "$appPath" --% /grant "%USERDOMAIN%\%USERNAME%":(F) /t # Delete directory Remove-Item $appPath -Recurse -Force -ErrorAction 0 }
We'll just have to wait until they come back with the next upgrade :)
You're welcome and yes - that's the idea... The Remove-Item line just means "delete the folder with whatever the name $apppath has" and the takeown and icacls lines are a pretty standard (if old fashioned) way to give yourself authority.
First off, many many thanks! Preforming a thread resurrection here to update the code:
the red section needs 'code'" instead of "code" in order to run.$appPath="$Env:LOCALAPPDATA\Packages\$app*"
Remove-Item $appPath -Recurse -Force -ErrorAction 0
$appPath = "$apppath = "C:\Program Files\WindowsApps\$app*"
# take ownership
takeown /f "$appPath" /r
So like this:
$appPath="$Env:LOCALAPPDATA\Packages\$app*"
Remove-Item $appPath -Recurse -Force -ErrorAction 0
$appPath = "$apppath = 'C:\Program Files\WindowsApps\$app*'"
# take ownership
takeown /f "$appPath" /r