Entra / Microsoft 365 ยท Teams
Report teams emojis
A quick and simple script to report the usage of emojis as reactions to Teams chat and channel conversation messages.
Connect & set up
Run these once per session. All scopes are read-only unless the script makes changes.
Connect-MgGraph -Scopes "User.ReadBasic.All"
Run it
The main script. Copy it, or download the .ps1 and run it from your console.
param([int] $LookbackDays = 360,[string] $StartDate = (Get-Date).AddDays(-$LookbackDays),[string] $EndDate = (Get-Date).AddDays(1))Connect-MgGraph -Scopes "User.ReadBasic.All"$UserInfoAvailable = $false# Fetching user information[array]$Users = Get-MgUser -All -PageSize 999 -Property DisplayName, UserPrincipalNameIf ($Users) {Write-Output ("Fetched {0} users from the tenant." -f $Users.Count)$UserHash = @{}ForEach ($User in $Users) {$UserHash.Add($User.UserPrincipalName, $User.DisplayName)}$UserInfoAvailable = $true} Else {Write-Output "No users found in the tenant."Break}# Check if Exchange Online is already connected - otherwise connectIf ($Null -eq (Get-ConnectionInformation)) {Write-Host "Connecting to Exchange Online..."Connect-ExchangeOnline -ShowBanner:$false}# Build hash table to resolve reaction name to the emoji shown in Teams$Emojis = @{}$Emojis.Add("head shaking vertically", "๐คฆโโ๏ธ")$Emojis.Add("head shaking horizontally", "๐คฆโโ๏ธ")$Emojis.Add("thumbs up", "๐")$Emojis.Add("thumbs down", "๐")$Emojis.Add("like", "๐")$Emojis.Add("heart", "โค๏ธ")$Emojis.Add("laugh", "๐")$Emojis.Add("peekingeye", "๐")$Emojis.Add("surprised", "๐ฎ")$Emojis.Add("sad", "๐ข")$Emojis.Add("saddog", "๐ถ")$Emojis.Add("angry", "๐ ")$Emojis.Add("yes-tone1", "๐๐ป")$Emojis.Add("blankface", "๐")$Emojis.Add("bowing", "๐")$Emojis.Add("call", "๐")$Emojis.Add("cool", "๐")$Emojis.Add("cry", "๐ข")$Emojis.Add("coolkoala", "๐ฆ")$Emojis.Add("eyeinspeechbubble", "๐๏ธโ๐จ๏ธ")$Emojis.Add("fire", "๐ฅ")$Emojis.Add("fistbump", "๐")$Emojis.Add("follow", "๐ฃ")$Emojis.Add("grinningfacewithsmilingeyes", "๐")$Emojis.Add("handsinair", "๐")$Emojis.Add("heartblue", "๐")$Emojis.Add("hearteyes", "๐")$Emojis.Add("happyface", "๐")$Emojis.Add("loudlycrying", "๐ญ")$Emojis.Add("personmotorwheelchairright2tone1", "๐ง๐ปโ๐ฆผ")$Emojis.Add("rainbowsmileyface", "๐")$Emojis.Add("clap", "๐")$Emojis.Add("smilingfacewithtear", "๐ฅฒ")$Emojis.Add("squintingfacewithtongue", "๐")$Emojis.Add("2714_heavycheckmark", "โ๏ธ")$Emojis.Add("mickeymouse;0-neu-d1-63cc7d1c9164d9a1b23ae85714dd20fa", "๐ญ")$Emojis.Add("think", "๐ค")$Emojis.Add("1f51c_soon", "๐")$Emojis.Add("1f6a2_ship", "๐ข")$Emojis.Add("1f4ce_paperclip", "๐")$Emojis.Add("relieved", "๐")$Emojis.Add("rofl", "๐คฃ")$Emojis.Add("peekingeyes", "๐")$Emojis.Add("1f3a8_artistpalette", "๐จ")$Emojis.Add("1f458_kimono", "๐")$Emojis.Add("1f4a4_zzz", "๐ค")$Emojis.Add("1f4af_hundredpointssymbol", "๐ฏ")$Emojis.Add("1f603_grinningfacewithbigeyes", "๐")$Emojis.Add("1f920_facewithcowboyhat", "๐ค ")$Emojis.Add("1f627_anguishedface", "๐ง")$Emojis.Add("1f911_moneymouthface", "๐ค")$Emojis.Add("1f915_facewithheadbandage", "๐ค")$Emojis.Add("1f4a1_electriclightbulb", "๐ก")$Emojis.Add("1f917_huggingface", "๐ค")$Emojis.Add("1f97a_pleadingface", "๐ฅบ")$Emojis.Add("1f92a_zanyface", "๐คช")$Emojis.Add("1f9b7_tooth", "๐ฆท")$Emojis.Add("203c_doubleexclamationmark", "โผ๏ธ")$Emojis.Add("1f440_eyes", "๐")$Emojis.Add("2795_heavyplussign", "โ")$Emojis.Add("2796_heavyminussign", "โ")$Emojis.Add("1f389_partypopper", "๐")$Emojis.Add("screamingfear", "๐ฑ")$Emojis.Add("womanraisinghand", "๐โโ๏ธ ")$Emojis.Add("support", "๐")$Emojis.Add("callme", "๐งโโ๏ธ")$Emojis.Add("Vampire-tone3", "๐ง๐ฝโโ๏ธ")$Emojis.Add("sweatgrinning", "๐ ")$Emojis.Add("ttm", "๐ถ")$Emojis.Add("oreoyum", "๐ช")$Emojis.Add("victory", "โ๏ธ")$Emojis.Add("vulcansalute", "๐")$Emojis.Add("rainbowsmile", "๐")$Emojis.Add("smile", "๐")$Emojis.Add("womandeveloper", "๐ฉโ๐ป")$Emojis.Add("whew", "๐ฎโ๐จ")# Find audit records for Teams emoji reactionsWrite-Output "Looking for audit records..."[array]$Records = Search-UnifiedAuditLog -StartDate $StartDate -EndDate $EndDate -Operations ReactedToMessage -Formatted -SessionCommand ReturnLargeSet -ResultSize 5000If ($Records.Count -eq 0) {Write-Output "No Teams emoji reaction records found"Break} Else {$Records = $Records | Sort-Object Identity -UniqueWrite-Output ("Found {0} Teams emoji reaction records to process..." -f $Records.Count)$Report = [System.Collections.Generic.List[Object]]::new()}# Genreate the reportForEach ($Rec in $Records) {$AuditData = $Rec.AuditData | ConvertFrom-JsonTry {$Emoji = $Emojis[$AuditData.MessageReactionType]} Catch {$Emoji = $null}If ($Null -eq $Emoji) {$Emoji = $AuditData.MessageReactionType}# Is the message from a chat or a channel conversation?$Channel = $AuditData.ChannelName$Team = $AuditData.TeamNameIf ($Null -eq $Channel) {$Channel = "Chat"$Team = $null}$Reaction = $AuditData.MessageReactionTypeIf ($null -eq $Reaction) {$Reaction = $AuditData.OldValue + " (Removed)"}# Get user displayname if user info is availableIf ($UserInfoAvailable) {$UserDisplayName = $UserHash[$Rec.UserIds]If ($Null -eq $UserDisplayName) {$UserDisplayName = $Rec.UserIds}} Else {$UserDisplayName = $Rec.UserIds}$ReportLine = [PSCustomObject][Ordered]@{User = $UserDisplayNameReaction = $ReactionEmoji = $EmojiReactionTime = $Rec.CreationDateChannel = $ChannelTeam = $TeamParentMessageId = $AuditData.ParentMessageIdUserId = $Rec.UserIds}$Report.Add($ReportLine)}$Report = $Report | Sort-Object {$_.ReactionTime -as [datetime]}$Report | Out-GridView -Title "Teams Emoji Reactions Report"Write-Output ""Write-Output "Top Ten Emoji reactions used in Teams"$Report | Group-Object Reaction -NoElement | Sort-Object Count -Descending | Select-Object -First 10 | Format-Table Name, @{name="Emoji"; Expression = { $Emojis[$_.Name] }}, Count -AutoSizeWrite-Output ""Write-Output "Top Ten Users who reacted with Emojis in Teams"$Report | Group-Object User -NoElement | Sort-Object Count -Descending | Select-Object -First 10 | Format-Table Name, CountWrite-Output ""# Export the report as an Excel worksheet or CSV fileIf (Get-Module ImportExcel -ListAvailable) {$ExcelGenerated = $trueImport-Module ImportExcel -ErrorAction SilentlyContinue$ExcelOutputFile = ((New-Object -ComObject Shell.Application).Namespace('shell:Downloads').Self.Path) + "\TeamsEmojiReport.xlsx"If (Test-Path $ExcelOutputFile) {Remove-Item $ExcelOutputFile -ErrorAction SilentlyContinue}$Report | Export-Excel -Path $ExcelOutputFile -WorksheetName "Teams Emoji Reactions" -Title ("Teams Emoji Reactions Report {0}" -f (Get-Date -format 'dd-MMM-yyyy')) -TitleBold -TableName "TeamsEmojiReactions"} Else {$CSVOutputFile = ((New-Object -ComObject Shell.Application).Namespace('shell:Downloads').Self.Path) + "\TeamsEmojisReport.CSV"$Report | Export-Csv -Path $CSVOutputFile -NoTypeInformation -Encoding Utf8}If ($ExcelGenerated) {Write-Output ("Excel worksheet output written to {0}" -f $ExcelOutputFile)} Else {Write-Output ("CSV output file written to {0}" -f $CSVOutputFile)}Write-Output "All done - enjoy the emoji data!"
Parameters
ParameterDefaultNotes
-LookbackDays360Number of days back to include Teams message emoji reactions.-StartDate(Get-Date).AddDays(-360)Start of the reporting window.-EndDate(Get-Date).AddDays(1)End of the reporting window.Attribution
Author
Office365itpros