${Graham Beer} = "blog"

App-V - Removal on Mass with PowerShell !

App-V, What is it ?

Well, Microsoft Application Virtualization is an application virtualization and application streaming solution from Microsoft. To break that down a bit more, a App-V application does not make changes directly to the underlying operating system’s file system and/or Registry, but rather is contained in an application-specific “bubble”. So this can be an excellent way to deploy applications to users within your company.
As a SCCM Administrator, the general involvement with applications is to deploy and remove. Its certainly useful to know how App-V works and the process involved to install on a computer. As App-V is primarily based on PowerShell, it means that installs and uninstalls have there own cmdlets.

During a recent rollout of Windows 8.1 I was heavily involved with, a question that came up many times was, “Application deployment, User or Device?”. Both have a place, but the main point to consider is how you manage software licenses. Deploying licensed applications to users can​ be troublesome. Even for instance if you mark the deployment in SCCM as, “Only deploy to primary device”. Consider this, a desktop engineer has a licensed software application deployed to his user account. He logs on many machines a week to troubleshoot various issues. Before you know it you’ve breached your license quota !
This is what happened to my company. A licensed application, deployed to users, got everywhere. So, how can we remove this application from all these devices ?

Many things to consider when removing a user targeted virtual application, as I found out. Getting a better understanding of how App-V works and working with PowerShell by using the “Get-Command” and “Get-Help” cmdlets on the App-V module, I came up with this script. I wanted to make the script generic, so I could reuse in the future. Lastly, how would SCCM be able to detect if the removal was a success ? To achieve this I added a parameter to specify a ‘.flg’ file (Flag file) to create in c:\windows\temp if the removal was successful, which I could reference in the detection settings of SCCM.
To help troubleshoot any failed removals I created a log file also in c:\windows\temp. I’ve used a ‘controller script’ to dot-source the main script into memory and hard coded the parameters for the sake of the SCCM uninstall deployment.

This script has worked well in my company, so I hope you find it some benefit. I’ve added the scripts to my GitHub to make it easier to get.