New PowerShell module for Microsoft Graph API reports

Azure AD & Microsoft 365 reports in a single module

In my work we use a lot of Microsoft APIs, especially the Microsoft Graph API.
Since the Graph API has many ways to optimize and change in bulk, I started with the Optimized.Mga module.

Only thing I noticed was that I often made the same reports and then I could make the same adjustments, spaces from property names, strings to arrays, bytes to gigabytes, etc.

So, on a rainy Sunday I decided to put the complete Azure AD & Microsoft 365 reports in a module so that from now on I only need a single cmdlet.

Got any questions? Please let me know in the comments.


Information about Optimized.Mga.Report

  • The module is a submodule of Optimized.Mga.
    This module will automatically installed when you install Optimized.Mga.Report.
  • The module uses the v1.0 reference.

For now it is not possible to use the beta version.
This is because the data is processed into clearer property names and arrays. These property names may not always match between the v1.0 and beta versions.

Module can be installed directly by using the following cmdlet.

Install-Module Optimized.Mga.Report -Scope CurrentUser

How can I interpret the Optimized.Mga.Report module?

Go to the Microsoft Graph API Docs and open the v1.0 reference reports.

As an example we use the following report:
reportRoot: getMailboxUsageDetail – Microsoft Graph v1.0 | Microsoft Docs

The module starts with Get-MgaReport by default.
We need the title of the reference. This is reportRoot: getMailboxUsageDetail.

Since Get and Report is already in the name, we only take the part that starts with a capital letter after the colon(:).

So in the example below we are using MailboxUsageDetail and the cmdlet becomes Get-MgaReportMailboxUsageDetail.

New PowerShell module for Microsoft Graph API reports
New PowerShell module for Microsoft Graph API reports

If you want to retrieve Microsoft 365 usage reports, you need at least this permission:

  • Reports.Read.All

If you want to retrieve Azure AD usage reports, you need at least these permissions:

  • AuditLog.Read.All
  • Directory.ReadWrite.All
  • Directory.Read.All

The official Microsoft Graph API PowerShell module VS my modules

I am aware that there is also an official Microsoft Graph API and submodule Microsoft Graph Reports from Microsoft.

Because this is not (yet) completely sufficient for myself, I started working on my own module.

The big difference in the main modules is the way of logging in & how easily you can adjust the request Uri’s without having to think about anything else.

My Microsoft Graph Report module has the advantage that the data has been processed.

For example:

  • With property names the spaces have been removed, the string data such as that of AssignedProducts property is automatically updated to an array.
  • It will be checked whether you have the correct permissions and if not, it will be indicated which one you are still missing.
  • Bytes are converted to Gb and for some cmdlets the free space is also returned.

The modules I made are purely for AzureAD App Registrations and Managed Identities.
It can be used as a user, but the idea behind the module is that it makes optimal use of speed and bulk optimizations that the Microsoft Graph API has to offer.

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work as a PowerShell DevOps Engineer. In my spare time I write about interesting stuff that I encounter during my work.

Leave a Reply

Your email address will not be published. Required fields are marked *