There are various reasons why the Outlook cache needs to be deleted. One of the most common reasons is after a migration, for example to Exchange online.
The Outlook cache can be deleted in various ways. However, as an administrator, we are interested in doing this centrally from one place.
In this article, I would like to point out two ways and describe a third way in more detail, as a kind of documentation.
Variant 1: (The Sneaker)
If the Outlook cache only needs to be deleted for individual users, this can be done with one of my scripts. The script with the name: ClearOutlookCache_M.ps1 (the GitHub link follows at the end of the article) is prepared for you.
The script works by first checking whether the path: C:\MDM\Logging exists, if this is not the case, this path is created.
The background to this is that a transcript is also created when the script is executed.
The system then checks whether the corresponding registry key exists. If this is the case, the script asks whether we really want to delete the corresponding key.
If this query is confirmed with “Y”, the key is deleted.
Outlook can then be restarted and the profile is set up again with Autodiscover.
Variant 2: (GPO)
During a migration, after which the deletion of Outlook profiles is generally recommended, we can also delete the cache using GPO settings. I wrote an article about this on Techgenix some time ago.
You can find out how to do this under the following link to my article:
Variant 3: (MS Intune)
I have also prepared a script for you for this variant. The script with the name: ClearOutlookCache_M.ps1 works as follows:
In the first step, the script checks whether the directory: C:\MDM\Logging exists, if not, this directory is created, similar to the ClearOutlookCache_M.ps1 script.
The script then checks whether the following registry key exists: HKCU:Software\Microsoft\MSB365_Outlook_clear_cache_Tool.
If this entry exists, the script terminates and makes no further changes (except for the corresponding log file in the previously defined path).
If the registry key does not exist, the Outlook cache is deleted and then the key “HKCU:Software\Microsoft\MSB365_Outlook_clear_cache_Tool” is created.
As this script is executed via MS Intune, this key ensures that the Outlook cache is not deleted each time the user logs in.
Conversely, this means for the administrators that if the cache is to be deleted again, this registry must be deleted beforehand.
The configuration of Intune so that this script is cancelled is as follows:
|In the Intune portal we go to Devices > Scripts
|Here we add a new PowerShell script.
|Distribute the script with the settings shown.
You can find the two scripts and a short readme under the following link:
As with all my scripts, the following principles apply:
The script can be used free of charge as described in the licence conditions. Changes are also allowed. However, when distributing or using the individual modules, reference must be made to this article and the MSB365 blog.
I strongly recommend testing the script in a LAB the first time you use it.
Likewise, I assume no liability for possible damage that the script may cause.
It is not allowed to pass on this script or single modules to third parties against payment. We follow the approach: From the community, for the community.