I'm developing application uninstaller using Powershell.
I using 2 commands:
Uninstall for all users (using -AllUser): Get-AppxPackage -AllUsers <PackageName> | Remove-AppxPackage -AllUsers
Uninstall specified user: Remove-AppxPackage <PackageName> -User <User SID>
Both commands I run using user admin.
Command 1. works fine. Command 2. doesn't work as expected.
Details about Command 2.
After I run 2/, I use command Get-AppxPackage <PackageName> -AllUsers
to check app installation status. The specified user's "PackageUserInformation" is [Installed(pending removal)]. Like the picture below. (Due to some security reasons, I cannot upload detailed images. I will add pictures later.)
I have tested on 2 environments:
- A) Windows 10 Pro 1909 => Uninstall successfully only when I sign in
that specified user
- B) Windows 10 Pro 2004 => Uninstall successfully
when I run command 2. and wait about 15 minutes (success includes
method A)
I have the following questions:
In case A, Why do I have to sign in again to be able to uninstall?
In case B, Why do I have to wait 15 minutes until the uninstall is complete?
What is a difference between the two versions of Windows? Is there an update to this issue?
I think this problem has to do with User's state (Active or Disconnected) and user's permission to access C:\Program Files\WindowsApps
. But I still can't find any documents related to this issue.
Because when using command 1. (Uninstall for All users) this problem does not occur.
If possible, please help me.
I greatly appreciate your support.
Thank you.