Deleting older cached versions of packages

Installing and managing an App-V 5.0 environment.

Moderators: kirk, jur, kkaminsk

Post Reply
mattkosht
Wanna Be AppVirtualizeR
Posts: 20
Joined: Sun Jan 31, 2010 4:00 am

Deleting older cached versions of packages

Post by mattkosht » Fri May 27, 2016 8:02 pm

Has anyone found a good method for periodically deleting unpublished or upgraded packages that App-V keep cached copies of on the client? I read this https://support.microsoft.com/en-us/kb/2768945 and am thinking of scripting something in PoSH to do this on scheduled basis.

seq_tim
Elder
Posts: 1218
Joined: Sat Sep 20, 2003 4:36 am
Location: Canton, MA (US)
Contact:

Re: Deleting older cached versions of packages

Post by seq_tim » Mon May 30, 2016 3:36 pm

That is the best way. It's easy for desktops, while RDS is problematic. There doesn't seem to be anything in the TechNet gallery on this, so it would be good for you to share there.

Borrowing from "TheGlobalizer" http://www.tmurgent.com/TmBlog/?p=2297 to trigger the PS script in the scheduled tasks might be best approach so that it happens automatically to systems that you target. You'd just look for older versions and remove whenever a publishing completes.
tim (Microsoft MVP for App-V)
Kahuna, TMurgent Technologies: http://www.tmurgent.com
President, Virtualization Boston: http://www.virtg.com

doc5avage
Still installing locally
Posts: 1
Joined: Mon May 30, 2016 9:50 pm

Re: Deleting older cached versions of packages

Post by doc5avage » Mon May 30, 2016 9:58 pm

I've thought about this before as disk space has been an issue in my org due to small SSD.
The issue is when running a script as system the Get-AppvClientPackage cmdlet returns all packages published to users as not published.
So the script either needs to run in user context or run through the profile list and user app data folders to check which apps are published before safely removing old ones.
For some reason I thought there was an unmount-appvclientpackage cmdlet which would have been a happy middle ground as the apps would simply redownload when the user launched them, but this doesn't exist.
If I can find some time later this week I'll have a crack at this script.

-Jesse

Tib
Guru
Posts: 219
Joined: Fri Jul 15, 2011 5:06 pm
Location: Belgium

Re: Deleting older cached versions of packages

Post by Tib » Mon May 30, 2016 10:45 pm

Running under system, use Get-AppvClientPackage -all to get a list of all applications. Only a admin account can actually remove the package from cache, so unless all your normal users are local admin, you must run the script under system context.
Do not forget to disable and remove (old) connectiongroups first, otherwise packages will get stuck.
The only possible issue you can run into is the fact that you will not unpublish those packages first if you assign them to users instead of machines.

I'm currently working on a script which will use the native appv backend to determine if a package is removed from the backend, and therefore can be removed from cache. As Tim suggests, use a scheduled task to trigger the script (logon, logoff (actually an event), lock, whatever).
Roy Essers | Tiberivs

seq_tim
Elder
Posts: 1218
Joined: Sat Sep 20, 2003 4:36 am
Location: Canton, MA (US)
Contact:

Re: Deleting older cached versions of packages

Post by seq_tim » Mon May 30, 2016 11:46 pm

Single user system (desktop) the user thing isn't important. You trigger on a publishing event, which gives you the guids and version of the new package, you then do the get-appvclientpackage with the -all parameter, cycle through looking for a matching packageId guid with different packageversion guid and remove.
tim (Microsoft MVP for App-V)
Kahuna, TMurgent Technologies: http://www.tmurgent.com
President, Virtualization Boston: http://www.virtg.com

RandyvonB
Wanna Be AppVirtualizeR
Posts: 12
Joined: Wed May 04, 2016 10:34 am

Re: Deleting older cached versions of packages

Post by RandyvonB » Tue May 31, 2016 12:43 pm

I actually had the same issue; I created following script to determine which packages do not have a user/or global deployment
We run this once a week from taskschedule;

Code: Select all

####################################
#                                             
# Written by:                      
# Randy von Bannisseht             
# Copyright:
# HelionIT                         
# Version: 0.4                     
# Date: 2016-05-31                 
#                                  
####################################

#Variables

$PKG = Get-AppvClientPackage -all |Where-Object {
                ($_.IsPublishedGlobally -ne "True") -and ($_.IsPublishedToUser -ne "True")
                         }
                                   

$pkgName = $pkg.name
$PKGID = $pkg.packageid 
$VRSID = $pkg.versionid

#Clean

$pkg|Remove-AppvClientPackage 
Remove-Item -path $env:Programdata\App-v\$PKGID\$VRSID -Recurse -ErrorAction SilentlyContinue 

Clear-Host 

mattkosht
Wanna Be AppVirtualizeR
Posts: 20
Joined: Sun Jan 31, 2010 4:00 am

Re: Deleting older cached versions of packages

Post by mattkosht » Tue May 31, 2016 10:55 pm

Tim - thanks it would make perfect sense to check for/remove older versions at publishing time!

I get an error on the Globalizer XML scheduled task when I try to create it from your site with copy/paste. Using Win 10 not sure if that is variable or not.

C:\WINDOWS\system32>schtasks /CREATE /RU System /TN "Microsoft\AppV\Publishing\TheGlobalizer" /XML "c:\Users\matt.kosht\Desktop\appv.xml"
ERROR: The task XML is malformed.
(1,2)::ERROR: incorrect document syntax
C:\WINDOWS\system32>

seq_tim
Elder
Posts: 1218
Joined: Sat Sep 20, 2003 4:36 am
Location: Canton, MA (US)
Contact:

Re: Deleting older cached versions of packages

Post by seq_tim » Wed Jun 01, 2016 4:49 pm

It was built for Windows 7 (since that is what most are using). It would need adjustment for WIn10, which I don't have time to do at present. But what I would do is manually create it in the Windows 10 Scheduled Task and export the file to a new xml file.

You get extra credit for posting the result back to me and I'll update the blog post giving you credit.

Tim
tim (Microsoft MVP for App-V)
Kahuna, TMurgent Technologies: http://www.tmurgent.com
President, Virtualization Boston: http://www.virtg.com

RandyvonB
Wanna Be AppVirtualizeR
Posts: 12
Joined: Wed May 04, 2016 10:34 am

Re: Deleting older cached versions of packages

Post by RandyvonB » Mon Jan 15, 2018 11:35 am

@Tim;

Windows 10 now has the option to clean old packages;

Set-appvclientconfiguration -AutoCleanUpEnabled 1

Post Reply

Return to “Installation and management (5.0)”

Who is online

Users browsing this forum: No registered users and 1 guest