How to Export Teams Chat History

Microsoft Teams data has many different locations. And while some locations make it easy to access and export data, others do not. Take Teams Chat History for example. This data lives in a folder of a Group mailbox. This, however, is not a typical mailbox and as such cannot be accessed in a typical way.

How to access and view contents of a GroupMailbox

First run this powershell command to get a list of all GroupMailboxes

Get-mailbox -GroupMailbox | select Displayname, WindowsEmailAddress

Using the WindowsEmailAddress run the following to view the details of the Mailbox folders for the desired Team. You will be able to view the item size of the TeamChat folder from the output.

Get-MailboxFolderStatistics -Identity “Group Email Address” | where {$_.FolderPath -eq “/Conversation History/Team Chat”} | select ItemsinFolder

How to export TeamChat data to a .pst file

Once you have verified the GroupMailbox and the TeamChat contents with PowerShell you will then need to head over the the Security and Compliance center in your Tenancy. Here we will configure and run a Search to get the contents of the MS Team you wish to export to PST

  • In the Security and Compliance Center choose Search and Content Search
  • Select Guided Search
  • Provide a Name, choose the Teams group as the location and add condition of Type: Equals any of E-mail messages and Instant Messages
  • Save and run the query
  • Select More from the menu items and choose Export Results
  • Choose All items and one PST for each mailbox and export results. Alternatively you can view the results directly from the Content Search or export a results report.
  • Once the results have been exported head over to Exports where you will then be able to select the file and download the PST. If you do not see a file select Refresh
  • Select the file and choose to Download the results. This will create a PST file that you can then choose to import or open outlook data file using Outlook desktop client and view the results. If you run into an issue running the E-Discovery export tool see this article to troubleshoot – HERE

Hopefully this helps!

16 responses to “How to Export Teams Chat History

  1. Getting following error:

    Get-mailbox : The term ‘Get-mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable
    program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + Get-mailbox -GroupMailbox | select Displayname, WindowsEmailAddress
    + ~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-mailbox:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    1. Install-Module PowershellGet -Force
      Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
      Install-Module -Name ExchangeOnlineManagement
      Get-Module ExchangeOnlineManagement -ListAvailable

  2. Found an easy way to copy/paste all the posts in a single channel. Go to any post and save the post by pointing to any post, then within the popup with the emoticons, click … then click Saved. Click on your profile icon (two initials or pic) and then click Saved. You will see the entire set of posts for the channel. From here you can start at the top and then hold the left mouse and drag (can’t do Cntl-A) to select all posts. Copy/Paste. Unfortunately, it includes the a url for EVERY POST so you may need to clean that up.

    1. I can copy the text, but I’m not able to paste the copied paste into say Notepad. The paste is just greyed like there is no text in the clipboard.

  3. And this why Teams will eventually go the Lotus way: it’s being bought by people who don’t use day to day, and would never choose it if it were their choice. You need to run scripts just to export a chat history.

  4. The problem with that approach is that there will be no subjects since Teams keeps it a separate property.
    It’s presented as Topic in Graph API Explorer

Leave a Reply

Your email address will not be published. Required fields are marked *