Deploy a PowerShell Script with Intune to remove Solitaire (or any other built-in Windows 10 app)

Our very first blog post on Device Advice was The modern way to remove Windows 10 in-box apps without them reinstalling. Although we recommend that method to everyone, there’s a few default apps that can’t be removed because they aren’t in the Business Store.

So we’re back to using PowerShell! The code here is fairly simple, since we’re just targeting one app in particular:

$listOfApps = get-appxpackage
$appToRemove = $listOfApps | where-object {$_ -like "*Solitaire*"}
Remove-AppxPackage -package $appToRemove.packagefullname

Let’s do a breakdown of each line.

get-appxpackage returns a list of all the app packages installed for a user profile. You can run this on your own device without admin rights, since it’s just returning a list.

get-appxpackage

We want to store that list in a variable, $listOfApps, so we can use it further. We’ll create another variable, $appToRemove, and query the $listOfApps variable for the one app we want – Solitaire. We use the wildcard characters (*) so we don’t need to know the exact name of the app. For reference, the fullpackagename will change depending on the Windows version.

If we call the variable $appToRemove after we’ve run the query, we’ll see the Solitaire appx package object:

$appToRemove object

And now the easy part – we uninstall the app by calling the remove-appxpackage PowerShell command and specifying the packagefullname. We can do this by calling the $appToRemove object and use a period with the property we want to call – thus, $appToRemove.packagefullname.

Now that we have the script, we just need to save it as a .ps1 file. I used PowerShell ISE to do this:

PowerShell ISE Solitaire Removal Script

To deploy, open the Microsoft Endpoint Manager admin center and click Devices > PowerShell Scripts > Add:

PowerShell scripts

For properties, I just named the script Remove Solitaire. The settings are important though – we want to select Run this script using the logged on credentials.

Script settings

Then assign the script to your Intune users group and you’re good to go!

If you use the Enrollment Statue Page, the script will run before the user has access to the desktop, which is an added bonus. Here’s how it looks on a brand new virtual machine I provisioned:

Remove Solitaire PowerShell script “installing” as an app
No Microsoft Solitaire Collection!

And just like that Solitaire is uninstalled! (The other app I was installing was Edge Beta, from a previous post).

You may also like...

4 Responses

  1. Janusz says:

    A quick update – Solitaire is back in the Business Store! Here is a direct link: https://businessstore.microsoft.com/en-us/store/details/microsoft-solitaire-collection/9WZDNCRFHWD2

    Or, search in the Business Store and select “Games” on the left hand side, to add the app to your Store for Business tenant and uninstall automatically using Intune. I’ll continue to leave this guide up incase there are other apps that need to be removed with PowerShell.

  2. Excellent blog post. I absolutely appreciate this site.
    Stick with it!

  3. RK says:

    I am new in powershell script. Quick question on this.. We need to add -executionpolicy bypass can you please let me know how i can add.

    • Janusz says:

      If you’re blocking script execution then I’m not sure this process will work for you. You could add “set-executionpolicy bypass -scope process” to the first line (before any of the other commands), but if scripts are blocked from running then it won’t even get to that line. Take a look at this troubleshooting guidance from the Microsoft Docs:

Leave a Reply

Your email address will not be published. Required fields are marked *