Products

1 min readMark all your Chat Messages in Microsoft Teams as ‘Read’ through PowerShell

1 min readMark all your Chat Messages in Microsoft Teams as ‘Read’ through PowerShell

Mark all Microsoft Teams personal chat messages as read using PowerShell.

In Microsoft Teams, in current world, it’s really a painstaking effort to mark your 1:1 chats as Read, especially when you have hundreds of them which have accumulated over your busy routine.

In this blog, you can find out how easily you can mark all your Personal Chat Messages as Read in a single shot, through PowerShell.

This script uses the built-in function
‘MgMarkChatReadForUser’
to iterate over the chats and get them marked as read.

Let’s get started!

Pre-requisites : Please install the Microsoft Graph PowerShell module before running this script.

All you need to do is :

  1. Execute the below script with the User UPN as parameter.
  2. Sign-in as the user whose chats to be marked as read.

Note : Please make sure you sign-in as the same user whose UPN you have provided as the parameter for the script.

function Read-TeamschatMessage
{  
     param (  
           $UserUPN
           )  
    process
    {
        Import-Module Microsoft.Graph.Teams  

        Connect-MgGraph -Scopes "Chat.ReadWrite" ,"User.Read"

        #To Get Tenant Id
        $Tenant= Get-MgOrganization 

        $TenantId= $Tenant.Id

        $Chats =Get-MgUserChat -UserId $UserUPN -ExpandProperty "members" 

        $User = $Chats[0].Members | Where-Object {$_.AdditionalProperties.email -eq $UserUPN} | select AdditionalProperties

        $UserId = $User.AdditionalProperties.userId

        foreach($chat in $Chats)
        {
            $params = @{

                User = @{
                    Id = $UserId
                    tenantId = $TenantId
                }
            }

            Invoke-MgMarkChatReadForUser -ChatId  $chat.Id -BodyParameter $params 
         }

         Disconnect-MgGraph
    }
}

Read-TeamsChatMessage -UserUPN ""

# For example
# Read-TeamsChatMessage -UserUPN "DeliaD@contoso.OnMicrosoft.com"  

Migrate Everything to Microsoft 365

Exchange Online SharePoint Online OneDrive For Business Microsoft Teams Microsoft Planner Viva Engage (Yammer) Microsoft Bookings Microsoft Forms Power Automate Microsoft Power BI Exchange Online SharePoint Online OneDrive For Business Microsoft Teams Microsoft Planner Viva Engage (Yammer) Microsoft Bookings Microsoft Forms Power Automate Microsoft Power BI
  • No Data Loss
  • Zero Downtime
  • ISO-Certified Protection

Start your free 15-days trial today !


4.5 out of 5

Bot Logo

Apps4.Pro Bot

Hey!👋 Ready to make your Microsoft 365 migration journey easier? Tell me what you’re looking.

What gets migrated?
I have a sales question
I'm here for tech support
Learn about Apps4.Pro