-
Notifications
You must be signed in to change notification settings - Fork 2
/
extra.ps1
31 lines (27 loc) · 1.37 KB
/
extra.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Get-GetLastMail($groupId) {
$query = "https://graph.microsoft.com/v1.0/groups/$groupId/conversations?`$top=1"
$headers = @{"Authorization" = "Bearer " + $token}
$result = Invoke-RestMethod -Method Get -ContentType "application/json" -Uri $query -Headers $headers -UseBasicParsing
if ($result.value.count -gt 0 ) {
lastDeliveredDateTime
}
return $result.value
}
function Get-LastTeamConversation($groupId) {
$channelQuery = "https://graph.microsoft.com/beta/teams/$groupId/channels"
$headers = @{"Authorization" = "Bearer " + $token}
$result = Invoke-RestMethod -Method Get -ContentType "application/json" -Uri $channelQuery -Headers $headers -UseBasicParsing
foreach ($channel in $result.value) {
$channelId = $channel.id
$messageQuery = "https://graph.microsoft.com/beta/teams/$groupId/channels/$channelId/messages?`$top=1"
$messageResponse = Invoke-RestMethod -Method Get -ContentType "application/json" -Uri $query -Headers $headers -UseBasicParsing
if ($messageResponse.value.count -gt 0) {
$msgDate = Get-Date -Date $messageResponse.value[0].createdDateTime
if ($msgDate -gt $lastMsgDate) {
$lastMsgDate = $msgDate
}
}
}
return $lastMsgDate
}
#planner https://graph.microsoft.com/v1.0/planner/plans/Yb02z6a-mkyh6I_Kela00pYAD3bv/tasks