This repository provides PowerShell scripts to export Microsoft Teams conversations in JSON format and optionally convert them to HTML for easy viewing.
The two PowerShell scripts in this repository serve the following purposes:
- Get-TeamsChatMessagesWithToken.ps1: Exports Microsoft Teams conversations to a JSON file by authenticating with a token.
- Convert-TeamsMessagesToHtml.ps1: Converts exported JSON messages into an HTML format for better readability.
- PowerShell 5.1 or later
- Admin access to Microsoft Teams API (with necessary permissions)
- Azure AD App Registration for token-based authentication
- Access to Microsoft Graph API
- Basic knowledge of PowerShell
-
Clone this repository or download the script file.
-
Run the PowerShell script with the following parameters:
./Get-TeamsChatMessagesWithToken.ps1 -ChatId <YourChatId> -AccessToken <YourAccessToken> -OutputFilePath <PathToSaveJson>
-
This script will authenticate using the provided token and export Teams messages into a JSON file at the specified path.
You can obtain the access token by logging in to Graph Explorer with your Microsoft tenant credentials. After logging in, select the necessary permissions (such as
Chat.Read
), and generate the token.
- Once you have the JSON file exported from the previous script, you can convert it to HTML.
- Run the following command:
./Convert-TeamsMessagesToHtml.ps1 -JsonPath <PathToJsonFile> -HtmlOutputPath <PathToSaveHtml>
- This script will read the JSON file and generate a formatted HTML file with the Teams conversations.
# Step 1: Export Teams Messages to JSON
./Get-TeamsChatMessagesWithToken.ps1 -ChatId "19:meeting_NjgxMjA0MGUtZmRiYy00MjY2LTlkYWMtOWJmYmEzYTA3YWZi@thread.v2" -AccessToken "eyJ..." -OutputFilePath "./teamsMessages.json"
# Step 2: Convert JSON to HTML
./Convert-TeamsMessagesToHtml.ps1 -JsonPath "./teamsMessages.json" -HtmlOutputPath "./teamsMessages.html"
To use the Get-TeamsChatMessagesWithToken.ps1
script, you'll need an access token for Microsoft Teams. This can be obtained through Azure AD or by logging in to Graph Explorer. Select the required permissions (e.g., Chat.Read
), authenticate, and copy the generated token to use in the script.
These sample files give an idea of the expected results when using the provided scripts to export Teams messages and convert them to HTML.
This project is licensed under the MIT License.