How can i successfully uninstall old version of microsoft store apps using powershell command in all user profiles

Salanje Banda 20 Reputation points
2023-09-07T16:06:12.0966667+00:00

I have been trying to deploy the below command through Sccm task sequence  to all the machine but unfortunately i still find the old version of the app still there.What am l m missing? This is one of the commands an using.

Remove-AppxPackage -allusers Microsoft.MPEG2VideoExtension_1.0.22661.0_x64__8wekyb3d8bbwe

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Configuration Manager | Other
Windows for business | Windows Client for IT Pros | User experience | Other
{count} votes

Accepted answer
  1. S.Sengupta 24,636 Reputation points MVP
    2023-09-08T00:49:47.2266667+00:00

    First, you should list the installed apps to identify the app names and their package names. Use the following command to list all installed apps:

    Get-AppxPackage -AllUsers | Select-Object Name, PackageFullName

    After identifying the app and its package full name, you can use the Remove-AppxPackage command to uninstall it.Replace "PackageFullName" with the actual package name of the app you want to uninstall.

    Get-AppxPackage -AllUsers | Where-Object { $_.Name -eq 'YourAppName' } | Remove-AppxPackage

    Replace 'YourAppName' with the name of the app you want to uninstall. Repeat this step for each app you want to remove.

    To uninstall these apps for all user profiles on the computer, you can use a ForEach loop to iterate through all user profiles and uninstall the app for each profile.

    $AppPackageName = "YourAppPackageFullName"
    
    $AllUserProfiles = Get-WmiObject -Class Win32_UserProfile | Where-Object { $_.Special -eq $false }
    
    foreach ($UserProfile in $AllUserProfiles) {
        $UserProfilePath = $UserProfile.LocalPath
        $UserProfileSID = $UserProfile.SID
    
        # Uninstall the app for the current user profile
        Invoke-Command -ScriptBlock {
            Get-AppxPackage -AllUsers -User $Using:UserProfileSID | Where-Object { $_.PackageFullName -eq $Using:AppPackageName } | Remove-AppxPackage
        }
    
        Write-Host "Uninstalled app for user profile: $UserProfilePath"
    }
    
    

    Replace "YourAppPackageFullName" with the package name of the app you want to uninstall.

    Save the script to a .ps1 file and run it with administrative privileges.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Salanje Banda 20 Reputation points
    2023-09-18T20:38:45.29+00:00

    I have these commands am using to remove the old versions of microsoft store app.If i run manually on the computer it is working but through sccm task sequence it failing.Is this command line correct in task sequence.

    User's image

    0 comments No comments

  2. Dana Loew 0 Reputation points
    2025-04-12T18:06:22.2166667+00:00

    When I've had troubles as described above, I discovered that the provisioned package had already been removed. You can find out if this is true in your case by using the Get-AppxProvisionedPackage -online command in an administrative powershell on the machine in question. Here is a link to more command syntax options:

    https://learn.microsoft.com/en-us/powershell/module/dism/get-appxprovisionedpackage?view=windowsserver2025-ps

    It appears that if the provisioned package has been removed then removal from the appxpackge list is more difficult.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.