Again and again we had to find out that sometimes App-V shortcuts in the user profile or even globally on the back. This can happen for various reasons. In particular, after a missing unpublishing for a user even if the package no longer exists. For nonpersistent VDI or Terminal Server this is no problem in the global context under C:\ProgramData\Microsoft\Windows\Start Menu\Programs, because the systems are always in their original state after a reboot.For user profiles, however, this is a problem.
Since I have a little more time right now, I finally get to publish the script I created a long time ago for this problem.
Clean-AppVLinks.ps1
How do I use this?The script can be included in the logon or logoff script or run independently. It can also be used via the Task Scheduler.Important is, it must run in the user context for links in the user directory and in the system context for the links of the system.The call Clean-AppVLinks.ps1 only cleans up the start menu.
Command Line Switches:
- -Desktop # also cleans up the user's desktop.
- -CleanUpEmptyFolders # If a folder is empty or becomes empty, the CleanUpEmptyFolders option deletes it
- -Global # Additionally the global folders are viewed and cleaned (also the desktop if -Desktop is set)
<# .SYNOPSIS delete all orphan app-v shortcuts of unpublished App-V applications .DESCRIPTION In App-V remain for a unpublishing sometimes shortcuts on the desktop or are in the Start menu (because of Profile Management or in use etc). This script looks which applications are published and delete the shortcuts of unreleased packages .PARAMETER -Desktop -Desktop : Clean up App-V Desktop icons .PARAMETER -Global -Global : Clean up Global links (c:\programdata\Microsoft\Windows\start menu, c:\Users\Public\Desktop) Need to run as Administrator .PARAMETER -CleanUpEmptyFolders -CleanUpEmptyFolders : Not an App-V Feature. Search for every empty folder in the "Start Menu" with the exception of "Autostart" and "Startup" and delete these folders. After a app-v synchonisation the App-V links are deletet. With exception of the parent folder .EXAMPLE & Clean-AppVLinks.ps1 -Global -Desktop & Clean-AppVLinks.ps1 -Desktop .NOTES .LINK .AUTOR Andreas Nick 2020 without warranty #>