|
1 | 1 | # Script to report active Teams
|
2 | 2 | # https://github.com/12Knocksinna/Office365itpros/blob/master/ReportActiveTeams.ps1
|
3 | 3 | # For Chapter 13 of Office 365 for IT Pros
|
| 4 | +# Updated because Microsoft changed the location of the Teams compliance records |
4 | 5 | Write-Host "Fetching list of teams..."
|
5 | 6 | $Teams = (Get-Team)
|
6 | 7 | Write-Host "Starting to process" $Teams.Count "teams"
|
7 | 8 | $Count = 0
|
8 | 9 | $Report = [System.Collections.Generic.List[Object]]::new()
|
9 |
| -ForEach ($T in $Teams) { |
| 10 | +ForEach ($T in $Teams | Sort DisplayName) { |
10 | 11 | $ActiveStatus = "Inactive"
|
11 | 12 | $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) { |
15 | 15 | Write-Host "Processing" $G.DisplayName
|
16 |
| - $TimeSinceCreation = (Get-Date) - $Folder.CreationTime |
| 16 | + $TimeSinceCreation = (Get-Date) - $TeamsData.CreationTime |
17 | 17 | $Count++
|
18 |
| - $ChatCount = $Folder.ItemsInFolder |
19 |
| - $NewestChat = $Folder.NewestItemReceivedDate |
| 18 | + $ChatCount = $TeamsData.ItemsInFolder |
| 19 | + $NewestChat = $TeamsData.NewestItemReceivedDate |
20 | 20 | $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) { |
23 | 24 | Write-Host "No Teams compliance records found for” $T.DisplayName -foregroundcolor Red
|
24 | 25 | $ChatsPerDay = 0
|
25 | 26 | $NewestChat = "N/A"
|
26 |
| - $ChatCount = 0 } } |
27 |
| - |
| 27 | + $ChatCount = 0 } |
28 | 28 | If ($ChatsPerDay -gt 0 -and $ChatsPerDay -le 2) { $ActiveStatus = "Moderate" }
|
29 | 29 | Elseif ($ChatsPerDay -gt 2 -and $ChatsPerDay -le 5) { $ActiveStatus = "Reasonable"}
|
30 |
| - Elseif ($ChatPerDay -gt 5) { $ActiveStatus = "Heavy" } |
| 30 | + Elseif ($ChatPerDay -gt 5) { $ActiveStatus = "Heavy" } |
31 | 31 |
|
32 | 32 | $ReportLine = [PSCustomObject]@{
|
33 | 33 | Alias = $G.Alias
|
|
0 commit comments