How to Count Microsoft Teams Messages for AI Labs

Find Teams message activity in the Microsoft 365 portal or count retained compliance records with PowerShell. Understand duplicates before reporting a total.

Workflows

On this page

You can count recent Teams message activity in the Microsoft 365 admin center, or use Exchange Online PowerShell to inventory retained Teams compliance records in selected mailboxes. Those results measure different things. Neither should be presented as an exact, deduplicated total of every message your company has ever sent.

For an AI data application, first ask whether the buyer wants recent activity, retained historical records or unique messages. Then choose the method and carry its definition into the questionnaire. This guide is part of our business data inventory for AI labs.

Understand the three possible counts

MetricWhat it answersWhat it does not establish
Sent-message activityHow many messages users posted during a report periodThe entire retained archive
Compliance recordsHow many matching stored records appear in the locations inspectedUnique messages across all locations
Unique messagesA count after a defined retrieval and deduplication processSomething you can derive by dividing compliance records by two

A chat record can be stored in several participants' mailboxes. Group chats are especially important: not every conversation has two people. Retention also changes which records remain available.

Teams live data and its Exchange compliance records are separate. Standard, private and shared channels have different compliance locations, which is why an inventory of employee mailboxes alone can miss channel content. Microsoft's Teams storage explanation (opens in a new tab)

Method 1 Use the Microsoft 365 portal

For a quick activity count, use an account with access to usage reporting:

  1. Sign in to the Microsoft 365 admin center (opens in a new tab).
  2. Open Reports → Usage → Microsoft Teams.
  3. Select User activity.
  4. Choose the required period, up to 180 days where available.
  5. Export the table and inspect Private Chat Message Count and Team Chat Message Count, using the definitions shown for the report.
  6. Add the relevant message columns across the intended users once. Record the reporting period, included users and report date.

Microsoft defines these as messages posted by users during the selected period. Channel messages already include posts and replies; do not add the separate Posts and Replies columns again on top of Channel messages. The report also has documented coverage limitations for service integrations. Teams activity metric definitions (opens in a new tab)

Write “[N] reported messages sent during [period].” If an application asks for years of retained chats, explain that this report covers recent activity and use a historical method instead.

Portal option for retained historical records

An administrator with the necessary eDiscovery access can use the Microsoft Purview portal (opens in a new tab). Open eDiscovery → Cases, create or open the inventory case, and create a search under Searches. Select the intended mailbox sources, including the relevant teams and channel coverage, rather than searching only the signed-in user's mailbox.

For a message-class starting filter, use the KeyQL editor:

itemclass:IPM.SkypeTeams.Message

Inspect a sample before expanding the search. A broader kind:microsoftteams filter can include additional Teams record types; record the query actually used and review what it returns. Microsoft's mailbox search properties (opens in a new tab)

Run the search with Statistics, download its report and record failed locations and indexing limitations. Call the result a search estimate. It is not automatically a unique-message total or a match for the diagnostic folder count below. Purview search count limitations (opens in a new tab)

If you lack the feature or role, ask your administrator for a scoped inventory. A missing screen is not evidence that the historical messages are gone.

Method 2 Inspect retained compliance folders with PowerShell

This method is a diagnostic inventory of named compliance folders. It can help explain where the stored records are, but folder names and coverage must be checked in your tenant. It does not retrieve message bodies or perform deduplication.

Install ExchangeOnlineManagement and connect with an account authorized to retrieve the statistics:

Install-Module ExchangeOnlineManagement -Scope CurrentUser
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName 'admin@yourcompany.com'

Inspect one mailbox's ordinary and hidden folder scopes before running a larger inventory:

Get-EXOMailboxFolderStatistics -Identity 'person@yourcompany.com' -FolderScope NonIpmRoot |
    Select-Object Name, FolderPath, FolderType, FolderId, ItemsInFolder |
    Format-Table -AutoSize

In a working inventory, folders named TeamsMessagesData and Team Chat revealed records that the initial visible-folder pass missed. The script below looks for those names, combines both scopes and avoids counting the same folder ID twice within a mailbox. Review the names before relying on this selection.

$ErrorActionPreference = 'Stop'
$inventoryDir = Join-Path (Get-Location) ('teams-inventory-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
New-Item -ItemType Directory -Path $inventoryDir -ErrorAction Stop | Out-Null
$users = @(Get-EXOMailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox,SharedMailbox)
$groups = @(Get-Mailbox -GroupMailbox -ResultSize Unlimited)
$targets = @(@($users) + @($groups) | Sort-Object PrimarySmtpAddress -Unique)
if ($targets.Count -eq 0) { throw 'No mailboxes found. Check Exchange access.' }
$coverage = [System.Collections.Generic.List[object]]::new()
$recordRows = @(foreach ($mailbox in $targets) {
    $address = [string]$mailbox.PrimarySmtpAddress
    $ordinary = @(Get-EXOMailboxFolderStatistics -Identity $address -ErrorAction Stop)
    $hidden = @(Get-EXOMailboxFolderStatistics -Identity $address -FolderScope NonIpmRoot -ErrorAction Stop)
    $allFolders = @($ordinary) + @($hidden)
    $candidates = @($allFolders | Where-Object { $_.Name -in @('TeamsMessagesData', 'Team Chat') })
    if (@($candidates | Where-Object { -not $_.FolderId }).Count -gt 0) {
        throw "A candidate folder has no ID in $address. Inspect its statistics."
    }
    $selected = @($candidates | Sort-Object FolderId -Unique)
    $coverage.Add([pscustomobject]@{
        Mailbox = $address
        CandidateFolders = $selected.Count
        Status = $(if ($selected.Count -gt 0) { 'Named folders found' } else { 'No named folders found; review coverage' })
    })
    foreach ($folder in $selected) {
        [pscustomobject]@{
            Mailbox = $address
            FolderPath = $folder.FolderPath
            FolderId = [string]$folder.FolderId
            ComplianceFolderItems = [long]$folder.ItemsInFolder
        }
    }
})
$coverage | Export-Csv (Join-Path $inventoryDir 'teams-mailbox-coverage.csv') -NoTypeInformation
if ($recordRows.Count -eq 0) { throw 'No named compliance folders found. This does not prove there are no Teams messages.' }
$recordRows | Export-Csv (Join-Path $inventoryDir 'teams-folders.csv') -NoTypeInformation
[pscustomobject]@{
    MailboxesInspected = $targets.Count
    NamedFolderItems = [long](($recordRows | Measure-Object ComplianceFolderItems -Sum).Sum)
    Scope = 'Named folders in selected primary user, shared and group mailboxes; not unique messages'
    CollectedAt = (Get-Date).ToString('o')
} | Format-List
Disconnect-ExchangeOnline -Confirm:$false

NonIpmRoot is a supported Exchange folder scope. The statistics can include hidden items, which is why the output remains a folder-item measurement. Exchange folder statistics reference (opens in a new tab)

The script stops on a retrieval failure. It also produces a coverage file: “no named folders found” means the name-based selection found nothing in that mailbox, not that the employee never used Teams. Shared-channel system locations, archive coverage and other storage arrangements need their own review; this is not an exhaustive all-channel export method.

Why 9,204 records did not mean 9,204 unique messages

One November 2026 inventory recorded 9,204 items across the selected Teams compliance folders. The first pass found only a handful of channel records because it missed hidden folders. Including those folders corrected the scope of the working inventory.

The notes also suggested a much smaller possible unique-message count. That was an approximation, not a deduplicated result. Dividing by two would assume all messages had exactly two stored participant copies, which group chats and channel storage do not support.

For an initial application, provide the measured compliance-folder total and its coverage. If the buyer requires unique messages, agree on retrieval scope, stable identifiers, edits, deletions and duplicate treatment before commissioning that next step.

Keep files and meeting records separate

Message volume does not tell you how many documents or recordings Teams contains. Those need their own inventories, including the relevant SharePoint sites and OneDrive accounts.

Likewise, a meeting-related record should not silently become another chat message. State the filter you used and preserve records excluded by that definition as a separate category if the buyer requests them.

For historical coverage, use the dates of the retained records you actually inspect. A reporting period, account creation date or folder existence alone does not prove that every message since that date remains available.

Paste this into the questionnaire

Teams: [count] [reported sent messages during the selected period/search-estimated records/named compliance-folder items]. Scope: [users, teams and locations]; collected [date]. Date coverage: [period or verified retained range]. This result [does/does not] represent unique messages. Duplicates, channel coverage and exclusions: [details].

Return to the full inventory checklist to keep each tool's unit clear. Once you have the relevant counts, check your company's fit for data licensing.

← All guides


MIT 2026 © Nextra.