I want to export my Microsoft Teams messages. Despite being both a dominant product in the market segment and run by a trillion dollar company, Teams doesn't have a native way for end users to export messages for work or school accounts.
The repository contains a PowerShell script that allows you to export your Microsoft Teams chat conversations, in HTML format, to your local disk.
If you are using Microsoft Teams with a personal Microsoft account, you can simply export your chats and other data with https://go.microsoft.com/fwlink/?linkid=2128346. This guide is for people using Microsoft Teams with work or school accounts.
Compared to other repos or methods that strive to achieve the same goal, this method is better in some respects:
This process will probably take you about 30s on a Windows system to get running or about 5m on MacOS or Linux and roughly 20m of unattended time to export 60 chats.
You should be able to skip this step! Continue to step 2.
See Microsoft's guide on installing PowerShell on MacOS.
See Microsoft's guide on installing PowerShell on Linux.
Open a PowerShell terminal. Type or copy the following into the terminal and hit enter.
irm https://raw.githubusercontent.com/evenevan/export-ms-teams-chats/main/ps.ps1 | iex
The script will ask you to authenticate an app named PnP Management Shell. Follow the instructions given. Sign in with your work/school email. If copying the device code, be careful as Ctrl + C is the same shortcut that halts the terminal; only press Ctrl + C once to copy.
If you run into issues with authentication, specifically with permissions requiring admin consent, there is not much I can do.
A few seconds after you finish authenticating, you should start seeing activity in the PowerShell terminal. Now, your chats will be fetched, processed, and exported. This may take a while. For me, it takes about 20 minutes for about 60 chats. As the script goes through the conversations, HTML files will start to appear in the output folder. Once done, put the contents of the output folder in a safe spot.
To view the exported chats, open the HTML files with your favorite browser.
Hopefully that is it! If you run into any issues, please let me know.
irm https://raw.githubusercontent.com/evenevan/export-ms-teams-chats/main/ps-verbose.ps1 | iex
in a PowerShell terminal../Get-MicrosoftTeamsChat.ps1 -Verbose
in a PowerShell terminal in the directory with the Get-MicrosoftTeamsChat.ps1
file.This repo is based on my improvements to the codebase of a pull request by olljanat (https://github.com/olljanat/MSTeamsChatExporter) on a repository by telstrapurple (https://github.com/telstrapurple/MSTeamsChatExporter).
I don't know what I'm doing. All I know is that this works (hopefully). There may be serious vulnerabilities or issues with the methods discussed. Under the MIT license, this comes with no warranty. Please don't sue me.