How can I delete Windows Apps (AppX) for Other Users

0

I have a large amount of drive space used in "c:\Program Files\WindowsApps..." that is for apps installed for other users. How can I remove those apps without logging in as that user?

In more detail, the 'other user' in this case is actually a old account of mine from before we migrated domains. I unfortunately cannot log on as the old user as the trust relationship between the domains has been lost and nobody seems willing or able to re-establish that trust relationship, so even Powershell Remove-AppxPackage doesn't work.

PS C:\WINDOWS\system32> Get-AppxPackage -all
Get-AppxPackage : The trust relationship between the primary domain and the trusted domain failed. (Exception from HRESULT: 0x800706FC) At line:1 char:1
+ Get-AppxPackage -all
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-AppxPackage], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.Windows.Appx.PackageManager.Commands.GetAppxPackageCommand

I do have admin access, am I OK to assign myself write permissions to the directories in question and just delete them? Seems a bit brutal, but I'm running out of ideas!

windows-10
powershell
uninstall
asked on Super User Nov 28, 2019 by steeveeet • edited Nov 29, 2019 by steeveeet

1 Answer

0

Avoid taking ownership of WindowsApps, since returning the ownership to TrustedInstaller is not possible, and in the future you will have problems with Windows Update.

It is entirely possible to use Remove-AppxPackage to remove a package for a user profile other than the profile of the current user, by using the -User parameter.

This parameter requires the SID of that user account as value, and also running the command as Administrator.

You may find the needed SID by running:

wmic useraccount where name='username' get sid
answered on Super User Nov 28, 2019 by harrymc

User contributions licensed under CC BY-SA 3.0