Run Get-AppxPackage -AllUsers *appxname* | Remove-AppxPackage" as system permission (SCCM Software Center)

I created a package that installs Waves MaxxAudio which is a modern application, and its installation uses a line that pulls the files folder where it contains the dependencies of the appx bundle. The installation running from the SCCM software center is perfect, but its removal is not. Researching I found that when running as a system the command “Get-AppxPackage” without the “-AllUsers” does not return MaxxAudio, so I put the command line like this:

Get-AppxPackage -AllUsers maxxaudio | Remove-AppxPackage"

But even so it doesn’t work, running as a user with admin permission, it works perfectly. How do I remove a modern app using the system account?

Because the installation works perfectly, but the uninstall doesn’t.

Hey @AegisShimon,

we’ve build that exact same Application with PSADT.
Please give this a try:

Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -match $(${FileName1} -replace '(^.*)_\d+\.\d+..*$', '$1') } | ForEach-Object {
    Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName -AllUsers -LogPath "${configToolkitLogDir}\${PackageName}_$($_.PackageName).log"

Where “FileName1” is that (Main)-Appx-File without the extension.

As far as i can tell this works for us.

Kind regards

1 Like

Hey @Baba, thank you so much for your help, and I apologize for the delay, I’ve been away for a while and now I’m back. I will test this out soon and will report it here once again, thank you so much for your help!

Hey @BaBa this uninstall command is extremely dangerous. I missed a letter in the name of the appxpackage and because of that, the command deleted all the existing WindowsApps in the operating system. Luckily I ran this inside a VM and was able to restore from a snapshot. Is this command correct?


tbh, i never saw such behavior.
I copied the command directly out of our WavesMaxxAudio-PSADT-File.

But, when looking over it and assuming an “empty” “Filename1”-Variable, that could be a match against every App, indeed.

We (and you obviously ^.^) may have a check for a valid “Filename1”-Variable beforehand ^.^