Remove App-V 5 Client Package with PowerShell

I’ve been doing a lot of testing with App-V 5 SP1 and System Center Configuration Manager 2012 SP1. I must say it’s much better than previous versions (in my environment anyway).

One thing I have found is removing App-V packages is a bit tedious – especially if you’re somewhat impatient like me!

As such I wrote a short script to help me remove any, or all, App-V packages from my machine:

Import-Module AppvClient
$Global:More = $True
Function RemoveApp
   {
      $AllPackages = Get-AppvClientPackage
      If ($AllPackages.Count -ge 0 )
      {
         $i = 1
         Write-Host "The following packages were found on this computer:"
         ForEach($Package in $AllPackages)
         {
            write-host `t $i - $Package.Name
            $i += 1
         }
         $NumbertoRemove = Read-Host "Which one would you like to remove? Type 0 if none"
         If ($NumbertoRemove -eq 0)
         {
            Write-Host "Not removing any App-V Client Package"
            $Global:More = $False
            Exit
         }
         else
         {
            If ($NumbertoRemove -le $AllPackages.Count)
            {
               $NumbertoRemove -= 1
               Write-Host "Removing package" $AllPackages[$NumbertoRemove].Name
               $PackageToRemove = $AllPackages[$NumbertoRemove]
               If ($PackageToRemove.IsPublishedGlobally)
                  {Unpublish-AppvClientPackage $AllPackages[$NumbertoRemove]}
               Remove-AppvClientPackage $AllPackages[$NumbertoRemove]
               Write-Host "AppV Client Package has been removed"
            }
            else
            {
               Write-Host "Number outside of bound. Please rerun script"
               $Global:More = $False
               Exit
            }
         }
      }
      else
      {
         Write-Host "No App-V Client Packages found!"
         Write-Host "Quiting!"
         $Global:More = $False
         Exit
      }
} 
Do {
   RemoveApp
   $Answer = Read-Host "Would you like to remove more? [y] Yes [N] No"
   If ($Answer.ToUpper() -ne "Y"){$More = $False}
}
while ($More -eq $True)

It enumerates all App-V packages available and allows you to pick which one to remove (or all of them if you wish to). If you need to you can use the script from my other post to sign it!

You can download the script from SkyDrive

Advertisements

Posted on 10 May, 2013, in Uncategorized. Bookmark the permalink. Leave a comment.

Anything to add? Let me know

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: