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!

4
  • Seems like ServerFault question to me but determining the folder locations for UWP apps and such should just be trivial and a simple Google search away e.g. C:\Program Files\WindowsApps, etc. – IT Thug Ninja Dec 1 '19 at 2:26
  • Another thought since you're talking "domains" and "trust relationships" here.... If the subnet(s)/network(s) of the other domain you need to run such commands against applicable domain user account profiles is accessible via the network even though the trust in not setup between the domains in the direction of the account you need that to run that command against. Try running the command with an explicit credential against the domain which does have access to it can authenticate and then run the commands rather than running it as a credential from the non-trusted domain. – IT Thug Ninja Dec 1 '19 at 14:44
  • A nice idea, but I'm completely unable to log in with credentials for the old domain - I've tried, but it's well and truly gone! – steeveeet Dec 2 '19 at 14:32
  • You might try unjoining the applicable computer from the non-existent domain then perhaps. Once that is complete and you wipe all the old non-existent domain profiles, you should be able to move forward as usual I would suspect. The root cause here is the non-existent domain and that machine still being joined to it and it not existing and having profiles from that domain on it still. You should be able to unjoin this PC from the domain it cannot access still with the domain not being accessible if I recall correctly. Give that some though, further resource, and a try. – IT Thug Ninja Dec 2 '19 at 18:40
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
3
  • 1
    It would be nice to explain the downvote. – harrymc Nov 28 '19 at 20:09
  • wmic useraccount where name='<<Myusername>>' get sid just gives ERROR: Description = Invalid query – steeveeet Dec 2 '19 at 14:34
  • Works for me. Try maybe to run CMD as Admin. If the problem still arrives, please include a screenshot of the command and the error message. – harrymc Dec 2 '19 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.