Skype Uninstall with Powershell

I cannot get the following command to run via the Powershell toolbox.

It runs fine if I execute it via the Powershell GUI, or if I run the RemoveSkype.ps1 manually.

Any help is appreciated:

Remove-AppxPackage -Package “Microsoft.SkypeApp_15.61.100.0_x86__kzf8qxf38zg5c”

Hi Drew,

The toolbox tool will be running as SYSTEM and as this is an AppX Package is likely tied to the user themselves, so it isn’t seeing the package under SYSTEM and taking no action.

If you use this syntax:

Get-AppxPackage -allusers Microsoft.SkypeApp_15.61.100.0_x86__kzf8qxf38zg5c | Remove-AppxPackage

This should hopefully do the trick. One suggestion I’d have is maybe to change it to:
Get-AppxPackage -allusers *SkypeApp* | Remove-AppxPackage

Then this would cover you for future use cases, as the PackageFullName will likely change in the future or an outdated version is installed on a system.

Thanks Anthony, although your solutions didn’t throw any errors, it didn’t remove the Skype App via a Toolbox.
Again, they do work via the Powershell GUI.

And this threw an error:
Remove-AppxPackage -Package “Microsoft.SkypeApp_15.61.100.0_x86__kzf8qxf38zg5c” -AllUsers

This article explains why it isn’t working.

Bottom line, I need to create a .bat file that executes the PowerShell script on next login. This will execute the script as the user, and not the system.

1 Like

Good Find. I use PDQ alot. They have good products and suggestions. Does seem odd MS doesnt even let the -AllUsers Command work as a system user. I tried several ways to get around it and was unsuccessful.

Nice one @Drew_Helgeson! Interesting reading.

These Appx packages are definitely a paradigm shift in how we go about our job. A lot of my users rely on OneDrive and a large percentage of helpdesk tickets are regarding this, and it takes a while to figure out how to create solutions that run as the logged in user to resolve OneDrive issues via the RMM. Thanks for linking the article.

The article logic is indeed correct, but the commands are not

The following works fine in 1909 (I was actually working on this today):

Remove for all users by exact package name

Get-AppXPackage Microsoft.SkypeApp* -AllUsers (to see who has it and get the package name)
Remove-AppxPackage -Package “Microsoft.SkypeApp_15.63.76.0_x86__kzf8qxf38zg5c” -AllUsers
Get-AppXPackage Microsoft.SkypeApp -AllUsers* - (to test if it was removed)

Remove it from the Provision as well so it doesn’t get reinstalled

Get-AppxProvisionedPackage -Online | where {$_.PackageName -like “Skype”} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue

Remove for a specific user (requires SID)

Get-LocalUser “username” SID (local)
Get-ADUser -Identity “username” | select SID (domain)

Remove-AppxPackage -Package “Microsoft.SkypeApp_15.61.100.0_x86__kzf8qxf38zg5c” -User “S-1-5-21-3843027404-195005032-2178188288-1004”

Scripted app name (two lines. Having issues with an one-liner passing over the package name - wip)

$AppToBeRemoved = Get-AppxPackage Microsoft.SkypeApp* -AllUsers | Select-Object -ExpandProperty PackageFullName
Remove-AppxPackage -Package “"$AppToBeRemoved”" -AllUsers

On some machines I had errors running this command:

Remove-AppxPackage -Package “Microsoft.SkypeApp_15.63.76.0_x86__kzf8qxf38zg5c” -AllUsers

The issue is the package manager is in a bad state. I was able to fix it by running this (it has no effect other than forcing the package manager to re-initialize), then re-run the initial command

Remove-AppxPackage -Package “Microsoft.SkypeApp_15.63.76.0_x86__kzf8qxf38zg5c”

Reference:

Remove-AppxPackage
[-Package]
[-AllUsers]
[-WhatIf]
[-Confirm]

Parameters

-AllUsers

This cmdlet removes the app package for all user accounts on the computer. This cmdlet works off the parent package type. If it is a bundle, use -PackageTypeFilter and specify the bundle. To use this parameter, you must run the command by using administrator permissions.

Thanks for the info Mike. I tested these in SimpleHelp (that runs a PowerShell script as SYSTEM) and they don’t work. Like I said in my original post, it will work if you run them manually, but not as SYSTEM.

Have you been able to get any to work using a toolbox? I’m still at a loss.

I did talk to support at PDQ about the article I linked, and they said they were able to fix this issue in PDQ and it will be in their next release. They wouldn’t tell me more, so I don’t know if they found a workaround, or if they got Microsoft to fix something and they are waiting for a patch. I don’t use PDQ, so I’ll wait to see what happens next.

Please let me know if you got this to work.

Thanks

Drew

Hey Drew,
I am running as a toolbox without any issues with SH
Send me a DM and I can email you my TB to test (just in case)

Mike if you do have this working, be sure to post your toolbox for it in the shared toolboxes section.
I would like to have it too. :slight_smile:

Yes, Mike_D, please share the details. This is what I ended up doing:

Prerequisites: I already have an account on each PC with the same ID/Password that made this possible.

  1. I created a toolbox with the following script line. This created a single task that executed as the local user at a specific time and then never runs again. The RemoveSkype.bat file was a resource added to the toolbox:
    SCHTASKS /CREATE /SC ONCE /RU UserNameHere /TN RunOnce /TR “C:\Scripts\RemoveSkype.bat” /ST 21:30

  2. In the RemoveSkype.bat, I had the following lines to remove the 2 current versions of skype, and then to delete the task called RunOnce (created in step 1):
    powershell Remove-AppxPackage -Package "Microsoft.SkypeApp_15.61.100.0_x86__kzf8qxf38zg5c"
    timeout 5
    powershell Remove-AppxPackage -Package "Microsoft.SkypeApp_15.63.76.0_x86__kzf8qxf38zg5c"
    SCHTASKS /DELETE /TN “RunOnce” /F

  3. I didn’t care if the .bat file remained in the Scripts folder, so I left it. But I could have created another toolbox to delete the file if I needed to.

You can use this same method to also change HKCU registry changes and anything else that needs to run as a local user instead of SYSTEM.

I hope there is a better way than this hacked together process.

Hope this helps.

Drew

Sorry for the late reply
I did manage a full TB with PS, and with Darrell worked on a generic script to remove any MS packages with PS/TB
It did well in my tests, I’d like more testers if anyone is willing to test/improve on my PS

Yes, please post the MS Package Remove PowerShell scripts you used in the ToolBox. I would appreciate it. I can give feedback on my testing.

PDQ just did a webcast on this:

Either of these scripts should work I believe. Just modify them to look for your software.
If someone would like to make these into a toolbox and use the simplehelp scripting api to popup a tech toolbox so they can enter the name of the software to remove so it wasn’t hard coded in the script, that would be cool.