Skip to content

Commit cdce820

Browse files
authored
Update ReportActiveTeams.ps1
Updated after Microsoft changed the location of the Teams compliance records
1 parent b165dc1 commit cdce820

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

ReportActiveTeams.ps1

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
# Script to report active Teams
22
# https://github.com/12Knocksinna/Office365itpros/blob/master/ReportActiveTeams.ps1
33
# For Chapter 13 of Office 365 for IT Pros
4+
# Updated because Microsoft changed the location of the Teams compliance records
45
Write-Host "Fetching list of teams..."
56
$Teams = (Get-Team)
67
Write-Host "Starting to process" $Teams.Count "teams"
78
$Count = 0
89
$Report = [System.Collections.Generic.List[Object]]::new()
9-
ForEach ($T in $Teams) {
10+
ForEach ($T in $Teams | Sort DisplayName) {
1011
$ActiveStatus = "Inactive"
1112
$G = Get-UnifiedGroup -Identity $T.GroupId | Select Alias, ManagedBy, WhenCreated, GroupMemberCount, DisplayName
12-
$TeamsData = (Get-MailboxFolderStatistics -Identity $G.Alias -FolderScope ConversationHistory -IncludeOldestAndNewestItems)
13-
ForEach ($Folder in $TeamsData) { # We might have one or two subfolders in Conversation History; find the one for Teams
14-
If ($Folder.FolderType -eq "TeamChat" -and $Folder.ItemsInFolder -gt 0) {
13+
$TeamsData = (Get-ExoMailboxFolderStatistics -Identity $G.Alias -FolderScope NonIpmRoot -IncludeOldestAndNewestItems | ? {$_.FolderType -eq "TeamsMessagesData"})
14+
If ($TeamsData.ItemsInFolder) {
1515
Write-Host "Processing" $G.DisplayName
16-
$TimeSinceCreation = (Get-Date) - $Folder.CreationTime
16+
$TimeSinceCreation = (Get-Date) - $TeamsData.CreationTime
1717
$Count++
18-
$ChatCount = $Folder.ItemsInFolder
19-
$NewestChat = $Folder.NewestItemReceivedDate
18+
$ChatCount = $TeamsData.ItemsInFolder
19+
$NewestChat = $TeamsData.NewestItemReceivedDate
2020
$ChatsPerDay = $ChatCount/$TimeSinceCreation.Days
21-
$ChatsPerDay = [math]::round($ChatsPerday,2)}
22-
If ($Folder.ItemsInFolder -eq 0 -and $Folder.FolderType -eq "TeamChat" ) {
21+
$ChatsPerDay = [math]::round($ChatsPerday,2)
22+
} #End if
23+
If ($TeamsData.ItemsInFolder -eq 0) {
2324
Write-Host "No Teams compliance records found for $T.DisplayName -foregroundcolor Red
2425
$ChatsPerDay = 0
2526
$NewestChat = "N/A"
26-
$ChatCount = 0 } }
27-
27+
$ChatCount = 0 }
2828
If ($ChatsPerDay -gt 0 -and $ChatsPerDay -le 2) { $ActiveStatus = "Moderate" }
2929
Elseif ($ChatsPerDay -gt 2 -and $ChatsPerDay -le 5) { $ActiveStatus = "Reasonable"}
30-
Elseif ($ChatPerDay -gt 5) { $ActiveStatus = "Heavy" }
30+
Elseif ($ChatPerDay -gt 5) { $ActiveStatus = "Heavy" }
3131

3232
$ReportLine = [PSCustomObject]@{
3333
Alias = $G.Alias

0 commit comments

Comments
 (0)