Retrieve Microsoft Teams User Activity Reports with Graph PowerShell

The Get-MgReportTeamUserActivityUserDetail cmdlet is part of the Microsoft Graph PowerShell module and is essential for administrators who need to retrieve detailed user activity reports for Microsoft Teams. This cmdlet helps in monitoring and analyzing the usage of Teams within an organization which is crucial for optimizing productivity and ensuring compliance.


Prerequisites

  • Graph PowerShell module installed (Microsoft.Graph).
  • Necessary Microsoft 365 admin role to access teams activity reports.
  • Basic knowledge of PowerShell scripting.

Installing the Microsoft Graph PowerShell Module

If you haven't installed the Graph PowerShell module yet, you can do so by running:

Install-Module Microsoft.Graph -Scope CurrentUser


Connecting to Microsoft Graph

First, you need to connect to Microsoft Graph with the required Graph API permission "Reports.Read.All":

Connect-MgGraph -Scopes "Reports.Read.All"
You will be prompted to authenticate. Ensure you log in with an account that has sufficient permissions.


Get-MgReportTeamUserActivityUserDetail Overview

The Get-MgReportTeamUserActivityUserDetail cmdlet generates a detailed report of user activities in Microsoft Teams for a specified date or period. The report includes various metrics such as the number of messages sent, meetings attended, and other collaborative activities.


Get-MgReportTeamUserActivityUserDetail Syntax


Get-MgReportTeamUserActivityUserDetail -Date  -OutFile  [-ResponseHeadersVariable <String>] [-Headers <IDictionary>] [-PassThru] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Get-MgReportTeamUserActivityUserDetail -Period <String> -OutFile <String> [-ResponseHeadersVariable <String>] [-Headers <IDictionary>] [-PassThru] [-ProgressAction <ActionPreference>] [<CommonParameters>]


                            

Parameters


  • -Date: Specifies the date for the report. This parameter is required if -Period is not specified.
  • -Period: Specifies the period for the report such as D7 for the last 7 days, D30 for the last 30 days, etc. This parameter is required if -Date is not specified.
  • -OutFile: Specifies the path where the output file will be written. This parameter is required.
  • -ResponseHeadersVariable: Optional. Stores the headers from the HTTP response.
  • -Headers: Optional. Adds additional headers to the HTTP request.
  • -PassThru: Optional. Returns true if the command succeeds.
  • -ProgressAction: Optional. Specifies how the progress of the command is shown.

Example Usage


Example 1: Generating a Report for a Specific Date

Get-MgReportTeamUserActivityUserDetail -Date "2024-06-01" -OutFile "C:\Reports\TeamsUserActivity_June1.csv"

This command generates a user activity report for June 1, 2024, and saves it to the specified file.


Example 2: Generating a Report for the Last 7 Days

Get-MgReportTeamUserActivityUserDetail -Period "D7" -OutFile "C:\Reports\TeamsUserActivity_Last7Days.csv"

This command generates a user activity report for the last 7 days and saves it to the specified file.


Practical Usage Scenarios


  • Monitoring Team Engagement: By regularly generating and analyzing user activity reports, administrators can monitor engagement levels across the organization. This helps in identifying users who might need additional training or support.
  • Ensuring Compliance: Activity reports can be used to ensure that team communication and collaboration adhere to organizational policies and compliance requirements.
  • Optimizing Resources: Analyzing the usage patterns helps in optimizing resources, such as adjusting the number of licenses or enhancing support for high-usage periods.

Troubleshooting Tips


Common Issues

  • File Path Errors: Ensure that the specified path in the -OutFile parameter is correct and that the directory exists.
  • Invalid Date/Period: Ensure that the -Date and -Period parameters are specified correctly. The date format should be YYYY-MM-DD.
  • Permission Issues: Ensure that the user executing the cmdlet has the necessary permissions to access the Microsoft Graph API and generate reports.

Example Errors and Solutions

Error: Invalid date format

Solution: Verify that the date is in the correct YYYY-MM-DD format.

Get-MgReportTeamUserActivityUserDetail -Date "2023-06-01" -OutFile "C:\Reports\TeamsUserActivity.csv"

Error: Access Denied

Solution: Ensure that the executing account has the necessary permissions in Azure AD and that the Microsoft Graph API permissions are correctly configured.


Additional Resources


Conclusion

By understanding and utilizing the Get-MgReportTeamUserActivityUserDetail cmdlet, administrators can effectively monitor and manage Teams usage within their organization, ensuring optimal performance and compliance.


Related Articles:

Using Get-MgDirectoryRole in Graph PowerShell
Using Get-MgUserLicenseDetail in Graph PowerShell
Using Find-GraphMgCommand in Graph PowerShell
Connect to Microsoft 365 Using PowerShell
How to Create Bulk Users in Office 365 Using Graph PowerShell?
Create Microsoft 365 Group Using Microsoft Graph PowerShell
Block Microsoft 365 User Using Microsoft Graph PowerShell
Assign Microsoft 365 License Using Graph PowerShell
Microsoft 365 User Management Using Graph PowerShell
Checking Group Membership in Microsoft 365
Bulk Assign Microsoft 365 License
Find Inactive Users in Microsoft 365
Using Powershell Graph Search Query
Using Powershell Graph Filter Query
Using Where-Object In Graph PowerShell
Using Expand Property In Graph PowerShell
Using Select Object In Graph PowerShell
Using -Contains Operator In Graph PowerShell
Add User to Multiple Microsoft 365 Groups Using Graph PowerShell
Import Microsoft 365 Groups from CSV File Using Graph PowerShell
Microsoft 365 Group User Import Using Graph PowerShell

© m365corner.com. All Rights Reserved. Design by HTML Codex