Clearing AX Client Cache for All Users on a RDS Host

Clearing AX Client Cache for All Users on a RDS Host

It’s AX code update time, and you’re needing to clear out everyone’s AX client side cache on your RDS host servers.

That’s a lot of user folders to do through.

Here’s what I do:

Let’s start with some assumptions.

  1. You have the AX client deployed using Remote Desktop Services (RemoteAPP)
  2. You are not using User Profile Disks

If that describes your environment, read on.  If not, or if it’s close, keep reading.  You may be able to modify my solution to fit your needs.

The goal:  Remove all local AX cache files for all users in the following locations:

  1. All files/folders starting with “vsa” located here: c$\users\%username%\Appdata\Local\Microsoft\Dynamics AX\
  2. All files ending in “*.kti” or “.auc” located here: c$\users\%username%\Appdata\Local


  1. User running the Powershell script must have full rights to each user folder on each RDS host server.  Domain Admin members in AD would be a good place to start for the quick and dirty way.
  2. You must run this on each RDS host server.

What it does:

  1. Users the command “get-childitem” under “c:\users” to generate a list of all folders
  2. Using “foreach”, it loops through every folder
  3. In each folder, it does a “get-item” under the specific AX client cache directories get all files/folders, then another “for-each” to delete them

The code:

#Specify Directory containing User folders
$userfolderlist = get-childitem -path c:\users -directory

#Remove AX Client Cache files for each folder
foreach ($item in $userfolderlist)
write-host "Removing Test AX cache for username $item"
            get-item "C:\Users\$item\AppData\Local\Microsoft\Dynamics Ax\vsa*" | foreach ($_) {remove-item $_.fullname -recurse}
            get-item "C:\Users\$item\AppData\Local\*.kti" | foreach ($_) {remove-item $_.fullname -recurse}
            get-item "c:\Users\$item\AppData\Local\*.auc" | foreach ($_) {remove-item $_.fullname -recurse}

***DISCLAIMER*** I am not responsible for this breaking or damaging any of your stuff.  Copyrights belong to their original owners***

Leave a Reply

Your email address will not be published. Required fields are marked *