How to generate activity report on Microsoft 365 groups and teams

How to generate activity report on 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 

$uri = "https://graph.microsoft.com/v1.0/groups?`$filter=groupTypes/any(a:a eq 'unified')"

[array]$Groups = Get-GraphData -AccessToken $Token -Uri $uri

If (!($Groups)) {Write-Host "Can't find any Microsoft 365 Groups - Check your access token"; break}

$i = 0

$GroupsList = [System.Collections.Generic.List[Object]]::new()

ForEach ($Group in $Groups) {

   $i++

   Write-Host ("Processing group {0} {1}/{2}" -f $Group.DisplayName, $i, $Groups.Count)

   $GroupOwnerEmail = $Null; $OwnerNames = $Null

 

 

Step 2: Get the list of group owners

$Uri = "https://graph.microsoft.com/v1.0/groups/" + $Group.Id + "/owners?"

   [array]$GroupData = Get-GraphData -Uri $Uri -AccessToken $Token

  If ($GroupData[0].'@odata.type' -eq '#microsoft.graph.user') {

# Extract owner names of groups

      $OwnerNames = $GroupData.DisplayName -join ", "

      $GroupOwnerEmail = $GroupData[0].Mail }

   Else { # ownerless group

       $OwnerNames = "No owners found"

       $GroupOwnerEMail = $Null }

 

Step 3: Get the list of extended group properties enabled

$Uri = "https://graph.microsoft.com/v1.0/groups/" + $Group.Id + "?`$select=visibility,description,assignedlabels"

   $GroupData = Get-GraphData -AccessToken $Token -Uri $uri

   $Visibility  = $GroupData.Visibility

   $Description = $GroupData.Description

   $GroupLabel  = $GroupData.AssignedLabels.DisplayName

 

Step 4: Get the SharePoint site URL 

$SPOUrl = $Null; $SPODocLib = $Null; $SPOQuotaUsed = 0; $SPOLastDateActivity = $Null

   $Uri = "https://graph.microsoft.com/v1.0/groups/" + $Group.Id + "/drive"

   [array]$SPOData = Get-GraphData -AccessToken $Token -Uri $uri

   [int]$LLVValue = $SPOData.WebUrl.IndexOf($SharedDocFolder)

   If (($SPOData.id) -and ($SPOData.DriveType -eq "documentLibrary")) {

       If ($LLVValue -gt 0) {

          $SPOUrl = $SPOData.WebUrl.SubString(0,$SPOData.WebUrl.IndexOf($SharedDocFolder))

          $SPODocLib = $SPOUrl + $SharedDocFolder2

          $SPOQuotaUsed = [Math]::Round($SPOData.quota.used/1Gb,2)

          $SPOLastDateActivity = Get-Date ($SPOData.lastModifiedDateTime) -format g

 

       }

       Else  {

         $SPOUrl = $SPOData.WebUrl

          $SPODocLib = $SPOUrl + $SharedDocFolder2

          $SPOQuotaUsed = [Math]::Round($SPOData.quota.used/1Gb,2)

          $SPOLastDateActivity = Get-Date ($SPOData.lastModifiedDateTime) -format g

       }

   }

   Else {

       CLS; Write-Host "Continuing to fetch information about Microsoft 365 Groups..."

 

Step 5: Get the member and guest member count 

$Uri = "https://graph.microsoft.com/beta/groups/" + $Group.Id + "/Members/Microsoft.Graph.User/`$count?`$filter=UserType eq 'Guest'"

   $GuestMemberCount = Get-GraphData -AccessToken $Token -Uri $uri

   $Uri = "https://graph.microsoft.com/beta/groups/" + $Group.Id + "/Members/Microsoft.Graph.User/`$count?`$filter=UserType eq 'Member'"

   $GroupMemberCount = Get-GraphData -AccessToken $Token -Uri $uri  

 

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

 

$ReportLine = [PSCustomObject][Ordered]@{

       DisplayName      = $Group.DisplayName

       ObjectId         = $Group.Id

       ManagedBy        = $OwnerNames

       GroupContact     = $GroupOwnerEmail

       GroupMembers     = $GroupMemberCount

       GuestMembers     = $GuestMemberCount

       SharePointURL    = $SPOUrl

       SharePointDocLib = $SPODocLib

       LastSPOActivity  = $SPOLastDateActivity

       WhenCreated      = Get-Date ($Group.createdDateTime) -format g

       WhenRenewed      = Get-Date ($Group.renewedDateTime) -format g

       Visibility       = $Visibility

       Description      = $Description

       Label            = $GroupLabel }

  $GroupsList.Add($ReportLine)

}

$GroupsList = $GroupsList | Sort DisplayName

 

Step 7: Get the list of teams

$uri = "https://graph.microsoft.com/V1.0/groups?`$filter=resourceProvisioningOptions/Any(x:x eq 'Team')"

[array]$Teams = Get-GraphData -AccessToken $Token -Uri $uri

$TeamsHash = @{}

$Teams.ForEach( {

   $TeamsHash.Add($_.Id, $_.DisplayName) } )

 

Step 8: List of all groups and teams found

$TeamsCount = $Teams.Count

$GroupsCount = $GroupsList.Count

If (!$GroupsCount) {Write-Host "No Microsoft 365 Groups can be found - exiting"; break}

If (!$TeamsCount) {Write-Host "No Microsoft Teams found in the tenant - continuing..." }

 

$S2 = Get-Date # End of fetching

CLS

Write-Host "Fetching data for" $GroupsCount "Microsoft 365 Groups took" ($S2 - $S1).TotalSeconds "seconds"

 

Step 9: Create output list 

$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 Settings > Org Settings > Services.
iii) Select Reports and clear Display concealed user, group and site names in all reports and click Save.

    • Related Articles

    • Microsoft 365 teams best practices

      Across all sizes of businesses, Microsoft Teams has become one of the most popular collaboration tools. Teams provides robust features that enable teams to collaborate and communicate effectively, regardless of their location. With so many features ...
    • 5 steps to securing Microsoft Teams

      What is Microsoft teams?   Microsoft Teams is an online collaboration platform with persistent chat and document sharing, as well as online meetings and other necessary features for communication. Teams, a component of the Office 365 suite, supports ...
    • Managing Microsoft 365 Groups and Teams for Collaboration and Productivity – best practices

      Introduction Microsoft 365 Groups and Teams are powerful tools for collaboration and productivity, allowing teams to work together seamlessly, share resources, and communicate effectively. However, managing these tools can be complex, especially when ...
    • How to prevent users from creating Microsoft Teams channels

      Introduction Microsoft Teams is becoming the modern workspace and more companies, groups, and individuals are adopting it. It helps users collaborate from remote locations, from multiple devices, without the risk of information silos or missed ...
    • Deep Dive into Microsoft 365 PowerShell Scripting

      Microsoft 365 lets administrators manage user accounts, licenses, settings, and more online via a web-based administrative console. Although the console provides a user-friendly interface for managing Microsoft 365, it can be complex when it comes to ...