Using Get-MgReportM365AppUserCount in Graph PowerShell

Tracking Microsoft 365 app usage is crucial for organizations looking to optimize licensing, monitor app adoption, and better understand user activity. The Get-MgReportM365AppUserCount cmdlet provides a convenient way to extract this data, enabling administrators to generate usage reports directly from Microsoft Graph PowerShell. This article explores the cmdlet’s syntax, showing how to generate app usage reports, and walks through its usage and common errors.

Cmdlet Syntax

Get-MgReportM365AppUserCount -Period <String> -OutFile <String> 

Parameters:

  • Period: Defines the time period for the report. For example, D30 retrieves data for the last 30 days.
  • OutFile: Specifies the location and name of the CSV file where the report will be saved.

Usage Examples

Example 1: Specifying Parameters Inline

This is the most common way to run the cmdlet, where both parameters are defined upfront.

Get-MgReportM365AppUserCount -Period D30 -Outfile C:/Users/d/Downloads/M365AppUsageReport.csv

This example generates a report for the last 30 days (D30) and saves it to the specified path.

Example 2: Run the Cmdlet Without Parameters

If you run the cmdlet without specifying parameters, it will prompt you to input them interactively:

Get-MgReportM365AppUserCount

The console will ask for:

  • -Period: A time period like D7 for 7 days, or D30 for 30 days.
  • -Outfile: The path where you want to save the CSV file.

Cmdlet Tips

  • Valid Period Values: The -Period parameter accepts values like D7, D30, etc., up to a maximum of D180. If you try to request data beyond 180 days, the cmdlet will fail.
  • File Format: The output is always in CSV format, making it easy to open and analyze with tools like Excel or Power BI. Ensure that the file path for -Outfile is correct to avoid file-saving errors.
  • Permissions: You need the Reports.Read.All permission to run this cmdlet successfully. Without this, the cmdlet will return an error stating insufficient permissions.

Possible Errors & Solutions

Error Cause Solution
Invalid Period Parameter The -Period parameter accepts values up to D180. Specifying a period beyond that (e.g., D270) will cause this error. Ensure that the period is within the allowed range (D1 to D180).
Access Denied or Insufficient Permissions The user running the cmdlet does not have the necessary permissions. Make sure that the user has been granted the Reports.Read.All permission through Microsoft Graph.
Invalid File Path The -Outfile parameter specifies an invalid or inaccessible file path Ensure the file path exists and the user has write access to the directory. For example, double-check the C:/Users/d/Downloads directory in the usage examples.
File in Use If the output file is already open or being used by another program (like Excel), the cmdlet will not be able to write to it. Ensure the target file is not in use when you run the cmdlet, or specify a different file name.

Use Cases

  • Monthly App Usage Reports: Use this cmdlet to generate monthly reports of Microsoft 365 app usage. By scheduling it to run automatically (e.g., using Task Scheduler), you can ensure that usage data is regularly collected and available for analysis.
  • App Adoption Monitoring: Organizations adopting new Microsoft 365 apps can use this cmdlet to track how often employees are using the apps over time, helping to identify which apps are widely adopted and which may require additional training or focus.
  • License Optimization: By tracking app usage, administrators can identify underutilized applications and optimize licensing to reduce costs. For example, if a specific app is being used infrequently, it might indicate an opportunity to reduce licenses.
  • Security and Compliance Audits: Understanding which applications are in use and by whom is crucial for security and compliance audits. This report can provide valuable insight into which apps are actively used in the organization, ensuring that licenses are allocated properly.

Conclusion

The Get-MgReportM365AppUserCount cmdlet is a powerful tool for Microsoft 365 administrators who need insights into application usage across their tenant. Whether you're monitoring app adoption, optimizing licenses, or conducting compliance audits, this cmdlet provides a straightforward way to generate usage reports. By understanding the cmdlet’s syntax, using it correctly, and handling possible errors, you can streamline reporting and ensure accurate data collection.

Suggested Reading

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