A customer recently asked me if the files uploaded to a Teams chat could be removed after a period of time. Although the capability to apply a retention policy to Teams chats to remove them after a period has been around for a very long time, it does not target the files that were uploaded during the chat. This is what the customer wanted to address.
The specific ask: “We want to delete all Teams chat files after 1 month to align with our deletion of Teams chats.”
Whether you agree with the ask or not isn’t the point of this post. The point is determining if it can be done and if so, how.
Short answer: yes
How? keep reading. 😊
The first thing to understand is that Teams chat files are stored in an auto-generated OneDrive folder named Microsoft Teams Chat Files. The second thing to understand is that this requirement cannot be accomplished with a retention policy… it requires a retention label since it is targeting a specific folder’s content.
To broaden my answer for this post, this post shows how to apply a retention label to content within any auto-generated OneDrive folder – something you may find yourself/your customer wanting to do.
Table of Contents
- 📂 Auto-generated OneDrive Folders
- 🏷️ Steps to apply retention labels
- ✍️ KeyQL reference for each folder
- ⚠️ Downsides to this approach
- ✅ Key takeaways
📂 Auto-generated OneDrive Folders
Whether you’ve noticed them or not, OneDrive automatically creates folders at the root of every users’ OneDrive document library to organize files from numerous Microsoft services. I’m assuming this is done so they can be resurfaced and shared across other Microsoft services in a reliable and consistent way. These folders are created on-the-fly and, as far as I can tell, aren’t created until a OneDrive user uses the service requiring it.
Knowing what these folders are named and what’s contained within them helps to inform the controls you may want to place on them.
Here’s a summarized visual that shows the folder names and a high level description of the content stored in each (as of September 2025):
‼️Important. 2 of the above auto-generated folders have built-in expiration/deletion and so you do not need to configure a retention label to do it for you unless you wanted to override the default behavior:
- Microsoft Copilot Chat Files: content is automatically deleted after 30 days (Privacy FAQ for Copilot)
- Recordings: content is subject to your tenant’s auto-expiration setting set in the Teams Admin Center
🏷️ Steps to Apply Retention Labels
What if you want to apply a retention label to content within a specific folder above? Let’s use the initial customer ask as an example:
The customer ask: “Delete all Teams Chat files after 1 month.”
Step 1: Create a Purview retention label
- Create a retention label configured to “Automatically delete after 1 month” (no retention required)
- Note: this requires a retention label and not a retention policy because you are targeting a specific folder’s content; not their entire OneDrive library
Step 2: Create an auto-apply retention label policy
- I strongly recommend you run this auto-apply label policy in simulation mode first before turning it on to validate the items that will be labeled
- Scope the label policy to the OneDrive accounts you want this applied to
- Select the option to Apply label to content that contains specific words or phrases, or properties” and enter this KeyQL as the condition:
- Note: the ParentLink is a queryable, managed property found on every file in SharePoint and OneDrive
- Select the retention label you created in step 1. This query will find all files that have a parent folder named “Microsoft Teams Chat Files” in the path above it (will include subfolder content) and automatically apply the retention label to the content within.
- It will NOT apply the retention label to the folder itself – only to the items within.
Step 3: Validation
Once you’ve turned on the auto-apply label policy, you may want to validate the retention label has been applied to the content in the above folder. There are 2 methods to do this:
- Scalable: Use Purview eDiscovery/Content search to look for your retention label in the OneDrive accounts scoped in your label policy.
- Thru the UI on your own OneDrive which is what I’m showing below.
- From the OneDrive… Settings… OneDrive settings… Return to classic OneDrive
- Create a classic view to include the retention label and when it was applied (Settings… Site contents… select the document library, create a new view)
- Navigate to the Microsoft Teams Chat Files folder
- You will see the retention label and the date it was applied. (in my test, the retention label is named Legal Matter TEST)
5. The label will be applied not only to items within the Microsoft Teams Chat Files folder, but also to any items in subfolders within that folder (not that any subfolder will likely be created in there, but I created a folder called Some random subfolder for testing purposes to show the label will be applied to content within it as well):
✍️ KeyQL reference for content in each auto-generated folder
The below KeyQL queries can simply target the ParentLink folder as shown in the above example or they can be more specific by also targeting other properties such as FileExtension or ProgID. In all cases, the retention label is applied to any matching items within the folder. Build the query to fit your requirements:
- 📂 Microsoft Teams Chat Files: parentlink:”Microsoft Teams Chat Files”
- 📂 Microsoft Copilot Chat Files: parentlink:”Microsoft Copilot Chat Files”
- Use only if the default 30 days is not sufficient
- 📂 Meetings: parentlink:”Meetings” AND FileExtension:loop
- 📂 Recordings: parentlink:”Recordings” AND ProgID:Media.Meeting
- Use only if the default expiration setting in the Teams Admin Center is not sufficient
- 📂 Attachments: parentlink:”Attachments”
- 📂 Whiteboards: parentlink:”Whiteboards” AND FileExtension:whiteboard
⚠️ 2 downsides to the ParentLink approach
- The folder name is hard-coded — which feels fundamentally wrong from an IT best practices standpoint and generally a big “no-no”. If Microsoft ever changes the folder name, the script wouldn’t break, but it would silently fail to apply the retention label to items within the new folder. That makes this a potentially frail setup. There is simply no other way to selectively target only a specific folder in OneDrive. Since these are auto-generated folder names controlled by Microsoft, there is some assurance the names will remain; although this is not guaranteed as the service changes over time.
- If a business user creates a subfolder in their OneDrive with the exact same name, the retention label would be applied to content in that folder as well — likely not the intended outcome. 🙂
✅ Key Takeaways
- Consider the 2 downsides to this approach I describe above.
- you can use the auto-generated folder name along with the ParentLink property to target items within the folder and apply a label to each unlabeled item found within
- this will include items that are directly under the ParentLink as well as items that may be in any subfolders under the ParentLink (tested and confirmed)
Thanks for reading!
-JCK




Will this approach work if users are in different languages, such as when Teams chat and recordings folders are in French or Japanese?
Since this approach is using the literal auto-generated folder name then as long as you have the folder name for French or Japanese users (is it the same or not, I don’t have a user to test that with), then it’s really just adding an additional OR condition on your KeyQL with that alternate language named folder.
A Purview content search will confirm the query for your environment. That’s what I would do before using it in an auto apply retention label policy.