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.

Connect-ExchangeOnline -UserPrincipalName [email protected]

Get-mailbox -GroupMailbox | select Displayname, WindowsEmailAddress

Using the WindowsEmailAddress, for the Team you wish to export messages from, run the following PowerShell to view the details of the Mailbox folders. 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 head over to the the Security and Compliance center in your Tenancy. Here you will configure and run a search to get the chat contents of the MS Team that you will export to a PST.

Steps

  • In the Security and Compliance Center choose Content Search
  • Select “New Search”
  • Provide a name, enable Exchange Mailboxes for specific locations and select Choose Users, groups or teams. Type the WindowsEmailAddress of the Group/Team from above PowerShell query.
  • Select Add Condition and choose Type Equals any of E-mail messages and Instant Messages
  • Review and submit you search
  • From the Content Search window review the status of your Search. Once it has completed select the Search, choose Actions and Export Results
  • From Export Results choose One PST file for each mailbox and select Export
  • Once the Export has finished select Export from the Content Search window and select your named search
  • Select the file. In the new window copy the export key then Download results. This will create a PST file that you can import or open as an 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

Hope this helps!

19 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
      Connect-ExchangeOnline

  2. Fantastic. Thanks! Some differences in the Tenant as MS improves, but easy enough to get through. Super useful!

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

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

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

  6. This assumes that the user has access to the Exchange server, which of course, most don’t.

  7. One possible workaround that might help, but is far from perfect, is to export to outlook. It puts the chat into a popup from which you can then use the usual select and copy and paste.

  8. It absolutely amazes me that Microsoft would make this so difficult. Whoever is in charge should quit and go into lawn care.

Comments are closed.