Generate an Activity Report for Microsoft 365 Groups and Teams

Generate an Activity Report for Microsoft 365 Groups and Teams

Introduction

The activity reports available for Microsoft 365 groups and Teams can be beneficial for administrators in an organization. Microsoft 365 teams group activity reports provide insight into group activities, group workloads, group counts, storage, and file counts. The reports can help admins identify inactive groups and teams.


Activity reports for Microsoft 365 groups and Teams

The activity reports for groups and teams provide insight into the activity of groups and teams in the organization. It is possible for administrators to see how many Microsoft 365 groups and teams there are and how they are being used.The Microsoft 365 group reports can provide comprehensive information about:

  • Sharepoint site files and storage quota used by the group
  • For team-enabled groups, the number of conversations in channels
  • Conversations in the inbox of the group



Generating an activity report for Microsoft 365 groups and Teams using PowerShell


Below is the step-by-step guide on getting activity reports for Microsoft 365 groups and teams using PowerShell.


Step 1: Create a list of M365 Groups in the tenant and a list of teams


  1. $uri = "https://graph.microsoft.com/v1.0/groups?`$filter=groupTypes/any(a:a eq 'unified')"
  2. [array]$Groups = Get-GraphData -AccessToken $Token -Uri $uri
  3. If (!($Groups)) {Write-Host "Can't find any Microsoft 365 Groups - Check your access token"; break}
  4. $i = 0
  5. $GroupsList = [System.Collections.Generic.List[Object]]::new()
  6. ForEach ($Group in $Groups) { 
  7.   $i++
  8.   Write-Host ("Processing group {0} {1}/{2}" -f $Group.DisplayName, $i, $Groups.Count)
  9.   $GroupOwnerEmail = $Null; $OwnerNames = $Null 



Step 2: Get the list of group owners


  1. $Uri = "https://graph.microsoft.com/v1.0/groups/" + $Group.Id + "/owners?"
  2.   [array]$GroupData = Get-GraphData -Uri $Uri -AccessToken $Token
  3.  If ($GroupData[0].'@odata.type' -eq '#microsoft.graph.user') { 
  4. # Extract owner names of groups
  5.      $OwnerNames = $GroupData.DisplayName -join ", " 
  6.      $GroupOwnerEmail = $GroupData[0].Mail }
  7.   Else { # ownerless group
  8.       $OwnerNames = "No owners found"
  9.       $GroupOwnerEMail = $Null }


Step 3: Get the list of extended group properties enabled.


  1. $Uri = "https://graph.microsoft.com/v1.0/groups/" + $Group.Id + "?`$select=visibility,description,assignedlabels"
  2.   $GroupData = Get-GraphData -AccessToken $Token -Uri $uri
  3.   $Visibility  = $GroupData.Visibility
  4.   $Description = $GroupData.Description
  5.   $GroupLabel  = $GroupData.AssignedLabels.DisplayName


Step 4: Get the SharePoint site URL


  1. $SPOUrl = $Null; $SPODocLib = $Null; $SPOQuotaUsed = 0; $SPOLastDateActivity = $Null
  2.   $Uri = "https://graph.microsoft.com/v1.0/groups/" + $Group.Id + "/drive"
  3.   [array]$SPOData = Get-GraphData -AccessToken $Token -Uri $uri
  4.   [int]$LLVValue = $SPOData.WebUrl.IndexOf($SharedDocFolder)
  5.   If (($SPOData.id) -and ($SPOData.DriveType -eq "documentLibrary")) { 
  6.       If ($LLVValue -gt 0) {
  7.          $SPOUrl = $SPOData.WebUrl.SubString(0,$SPOData.WebUrl.IndexOf($SharedDocFolder))
  8.          $SPODocLib = $SPOUrl + $SharedDocFolder2 
  9.          $SPOQuotaUsed = [Math]::Round($SPOData.quota.used/1Gb,2)
  10.          $SPOLastDateActivity = Get-Date ($SPOData.lastModifiedDateTime) -format g 

  11.       } 
  12.       Else  { 
  13.         $SPOUrl = $SPOData.WebUrl
  14.          $SPODocLib = $SPOUrl + $SharedDocFolder2 
  15.          $SPOQuotaUsed = [Math]::Round($SPOData.quota.used/1Gb,2)
  16.          $SPOLastDateActivity = Get-Date ($SPOData.lastModifiedDateTime) -format g 
  17.       } 
  18.   } 
  19.   Else { 
  20.       CLS; Write-Host "Continuing to fetch information about Microsoft 365 Groups..."


Step 5: Get the member and guest member count


  1. $Uri = "https://graph.microsoft.com/beta/groups/" + $Group.Id + "/Members/Microsoft.Graph.User/`$count?`$filter=UserType eq 'Guest'"
  2.   $GuestMemberCount = Get-GraphData -AccessToken $Token -Uri $uri
  3.   $Uri = "https://graph.microsoft.com/beta/groups/" + $Group.Id + "/Members/Microsoft.Graph.User/`$count?`$filter=UserType eq 'Member'"
  4.   $GroupMemberCount = Get-GraphData -AccessToken $Token -Uri $uri  


Step 6: Update the list with group information collected with the previous scripts


  1. $ReportLine = [PSCustomObject][Ordered]@{
  2.       DisplayName      = $Group.DisplayName
  3.       ObjectId         = $Group.Id
  4.       ManagedBy        = $OwnerNames
  5.       GroupContact     = $GroupOwnerEmail
  6.       GroupMembers     = $GroupMemberCount
  7.       GuestMembers     = $GuestMemberCount
  8.       SharePointURL    = $SPOUrl
  9.       SharePointDocLib = $SPODocLib
  10.       LastSPOActivity  = $SPOLastDateActivity
  11.       WhenCreated      = Get-Date ($Group.createdDateTime) -format g 
  12.       WhenRenewed      = Get-Date ($Group.renewedDateTime) -format g
  13.       Visibility       = $Visibility
  14.       Description      = $Description
  15.       Label            = $GroupLabel }
  16.  $GroupsList.Add($ReportLine) 
  17. $GroupsList = $GroupsList | Sort DisplayName


Step 7: Get the list of teams


  1. $uri = "https://graph.microsoft.com/V1.0/groups?`$filter=resourceProvisioningOptions/Any(x:x eq 'Team')"
  2. [array]$Teams = Get-GraphData -AccessToken $Token -Uri $uri
  3. $TeamsHash = @{}
  4. $Teams.ForEach( {
  5.   $TeamsHash.Add($_.Id, $_.DisplayName) } )


Step 8: List of all groups and teams found

  1. $TeamsCount = $Teams.Count
  2. $GroupsCount = $GroupsList.Count
  3. If (!$GroupsCount) {Write-Host "No Microsoft 365 Groups can be found - exiting"; break}
  4. If (!$TeamsCount) {Write-Host "No Microsoft Teams found in the tenant - continuing..." }

  5. $S2 = Get-Date # End of fetching
  6. CLS
  7. Write-Host "Fetching data for" $GroupsCount "Microsoft 365 Groups took" ($S2 - $S1).TotalSeconds "seconds"


Step 9: Create output list


  1. $Report = [System.Collections.Generic.List[Object]]::new(); $ReportFile = "c:\temp\GroupsActivityReport.html"



Generating an activity report for Microsoft 365 groups and Teams using Microsoft 365 admin center



The reports dashboard in Microsoft 365 shows the activity overview across the products in the organization. The reports can be accessed by global admins, teams service admins, and global readers. These reports enable the admins to get insights within each product. Admins can view the user activity reports, last activity reports Below is the step-by-step guide to access reports in the admin center in Microsoft 365.

i) In the admin centre, choose Reports, and select Usage.
ii) In the Dashboard home page, click on the View more button on the Active users - Microsoft 365 Apps or the Active users - Microsoft 365 services card to get to the Office 365 report page.

iii) You can view the activations in the Office 365 report by choosing the Group Activities tab.

iv) You can also export the report data into an excel or .csv file by selecting the Export link. This exported data of all users enables admins to do simple sorting and filtering for further analysis.


Microsoft, from September 1, 2021, are hiding user information by default for all reports to help companies support their local privacy laws. To enable the display name in the user activities report, the global admins can follow the steps given below:

i) Go to Microsoft 365 admin center.

ii) Go to SettingsOrg SettingsServices.

iii) Select Reports and clear Display concealed user, group and site names in all reports and click Save.

    • Related Articles

    • How to find unused Exchange Online mailboxes

      What are unused Exchange Online mailboxes and how to identify them? Unused Exchange Online mailboxes are user mailboxes which are currently not being used by their users. There are 3 ways in which we can identify if a mailbox is unused or not. They ...
    • How to monitor Microsoft 365 email and mailbox activity with PowerShell

      Monitoring Microsoft 365 email and mailbox activity with PowerShell can be a crucial part of managing your organization's email security and compliance. With PowerShell, you can quickly and easily automate the process of monitoring email and mailbox ...
    • How to create and manage Microsoft 365 groups with PowerShell

      Introduction: Microsoft 365 Groups is a collaboration feature that allows users to work together and share resources such as calendars, files, and email messages. Microsoft 365 Groups can be created and managed using the Microsoft 365 admin center, ...
    • How to retrieve and analyze Microsoft 365 usage data with PowerShell

      Retrieving and analyzing Microsoft 365 usage data with PowerShell can provide valuable insights into how your organization is using Microsoft 365 services, which can help you optimize your environment and improve user productivity. In this ...
    • PowerShell for AD user reports

      Real-time insights on user account status and activity can help AD  administrators manage accounts better. Many administrators use Microsoft's PowerShell scripts to generate Active Directory reports  and pull detailed information. Below are some ...