I suck at time cards. Part of it is that I'm jumping between 30 tasks at once - help this team, help that team, training, documentation, and my sprint work. At the end of the day I have a bare-ass notebook with a few cryptic lines about what I did today - if I'm lucky.
But a lot of it is available elsewhere. We're all virtual now, so all my interactions are either voice calls, meetings, or chats. I want to list out what I did in a given day so I can reconstruct it - how much time I spent helping whom.
Enter Microsoft Graph. It's an API that selects from it. There's a set of cmdlets that let you do quite a bit. I really do wish the get-mgchatmessagedelta properly handled "-filter" to make this faster, but I'll cope.
This will rip through ALL your chats, then for each one get the most recent 200 messages, filter it down to the past day or two, then toss it out on a format-table.
My pain, your gain. It's always fun when there's 2 google results for something.
Install-Module Microsoft.Graph
Import-Module Microsoft.Graph.Teams
$RequiredScopes = @("Chat.ReadBasic", "Chat.ReadWrite")
Connect-MgGraph -Scopes $RequiredScopes
get-mgchat
get-mgchat -ChatId 19:deadbeefb2d949d88d4455f5279e5d8b@thread.v2
get-mgchatmessage -ChatId 19:deadbeefb2d949d88d4455f5279e5d8b@thread.v2
$tzone = Get-TimeZone
$mychats = get-mgchat -all -PageSize 50 |select -first 5
$all_chat_info = @()
$all_chat_info = foreach ($chat in $mychats) {
$chatinfo = get-mgchat -ChatId $chat.id
$chatname = $chat.Topic
$members = $chat.Members
$chattype = $chat.chattype
$recentchatmessages = get-mgchatmessage -ChatId $chat.id -top 200 -pagesize 50 |where {$_.LastModifiedDateTime.tolocaltime() -gt (get-date).date.AddDays(-1)}
$recentchatmessages | select @{Label='LastModified';Expression={($_.LastModifiedDateTime.tolocaltime())}}, @{Label='ChatName';Expression={($chatname)}}, @{Label='members';Expression={($members)}}, @{Label='ChatType';Expression={($chattype)}},
@{Label='From';Expression={($_.from.user.displayname)}}, @{Label='Body';Expression={ ($_.Body.content -split '\n')[0] -replace '<[^>]+>',''}}
}
$all_chat_info|format-table
Disconnect-MgGraph