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...

Leave a Reply

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