attituding / export-ms-teams-chats

Export Microsoft Teams Chats to a local HTML file
MIT License
44 stars 6 forks source link

Microsoft Teams Chat Exporter

Example of Exported Chat

Introduction

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.

Important

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.

Advantages

Compared to other repos or methods that strive to achieve the same goal, this method is better in some respects:

Guide

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.

1. Install PowerShell 7

Windows

You should be able to skip this step! Continue to step 2.

MacOS

See Microsoft's guide on installing PowerShell on MacOS.

Linux

See Microsoft's guide on installing PowerShell on Linux.

2. Run the Script

Open a PowerShell terminal. Type or copy the following into the terminal and hit enter.

irm https://attituding.github.io/export-ms-teams-chats/ps.ps1 | iex
Legacy/Alternate Method **Only use this method if the above doesn't work for you. This is almost certainly more difficult.** [Download my code](https://github.com/attituding/export-ms-teams-chats/archive/refs/heads/main.zip). Then, extract the downloaded folder to wherever is convenient to you. #### [Easier] Windows - Through File Explorer 1. Find the `Get-MicrosoftTeamsChat.ps1` file in File Explorer and right click it. 2. Click `Run with PowerShell`. - If you get a security warning when clicking run, press open to continue. For doubts of the code's intentions, you can verify the code yourself since it is open source. - You may need to run `Set-ExecutionPolicy RemoteSigned` to allow the script to run. - You may be prompted to confirm if you want to change the execution policy to continue. #### [Harder] All OSs - Through the terminal 1. Open PowerShell. 2. In the terminal, navigate to the folder with the `Get-MicrosoftTeamsChat.ps1` file. 3. Run `./Get-MicrosoftTeamsChat.ps1`.

3. Authenticate

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.

4. Wait

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.

5. View

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.

Notes

General

Debugging

Credit

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).

Disclaimer

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.