Summary: Microsoft Scripting Guy, Ed Wilson, talks about uninstalling modern apps.
Microsoft Scripting Guy, Ed Wilson, is here. It is the weekend here in Charlotte, North Carolina. The Scripting Wife decided that we would go to the Blue Ridge Classic Horse Show today, so she actually got up early, and got everything ready for the trip. She even packed a feed sack (for me—not for the horses). Personally, I like watching the little Roadster Ponies, but Teresa likes the Friesians. Our good friend, Microsoft PowerShell MVP, Jeff Wouters, even arranged for us to go see some Friesian horses in Friesland when we were in Holland. They are impressive beasts. Here is a picture I took during the show.
Over the years, the Scripting Wife and I have been to several horse shows, and one thing that is interesting is that over time our tastes have changed. I used to like the five-gaited show pleasure horses. She used to like the Western-saddle bred horses before she fell in love with the Friesians. The same thing is true of software, especially with the modern apps. They are so easy to download and install from the store, that I hardly give much thought to them. I download them, and if I do not use them very much, I uninstall them. Here is part of my Start screen:
To uninstall a modern app, I use the Remove-AppxPackage. The problem is that this cmdlet requires a package name, which is generally really, really long. It does not accept wildcard characters either. In the following image, I attempt to remove a modern app, but I get an error message. The message is a bit misleading because it complains that I do not have the software package installed—but of course, I do.
The cause of the error message is that it is looking literally for a package named *pricedetective* and it is not finding it. The solution is to use the Get-AppxPackage cmdlet to find the package. This is because the Windows PowerShell Get-AppxPackage cmdlet accepts wildcard characters for the package name. This is shown here:
Because Remove-AppxPackage accepts piped input, I can use wildcard characters to find the package with Get-AppxPackage, and then send the results over the pipeline to remove the package. Depending on how long it takes to uninstall the package, a progress bar may appear at the top of the Windows PowerShell console to indicate that the command is working. The command is shown here:
Get-AppxPackage -Name *pricedetective* | Remove-AppxPackage
Removing multiple apps
Remember (I have said it many times)…PowerShell is PowerShell is PowerShell. This means that properly designed, well-behaved Windows PowerShell cmdlets all work the same. This means I can use standard Windows PowerShell techniques such as arrays, the Foreach-Object, and the pipeline. By putting them together, I can remove multiple applications as easily as I can remove one package. The following command removes a couple of applications that I have installed on my computer:
"*greenville*","*magnetophone*" | foreach {Get-AppxPackage $_ | Remove-AppxPackage}
While the command runs, it creates a progress bar as shown here:
When I am done, I run the Get-AppxPackage command to ensure that I did indeed remove the applications. Nothing returns, which means they are gone.
"*greenville*","*magnetophone*" | foreach {Get-AppxPackage $_ }
I bounce back to my Start screen. Sure enough—it is cleaned up a bit.
I have the apps cleaned up, and now the Roadster Pony-Limit Pony class is up, so I have to go. Who knows, I might find another favorite class. The only problem is that there is no Remove-ShowPony cmdlet. Oh well. I hope you enjoy the rest of your weekend. Join me tomorrow for more cool Windows PowerShell stuff.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy