M365: Active users and licenses overview
From time to time you need an overview of active users in your Microsoft 365 environment to clean up license assignments. Especially in larger scale environments this can be a challenge. As I needed a quick way to get this information (users with their last login to Azure AD and their assigned licenses), I developed a small script to leverage the Graph API (beta) to retrieve the information. The data retrieved is exported into a CSV file that can easily be filtered and formatted using Microsoft Excel.
Please be aware, that I wrote it in PowerShell 7 and with the module Microsoft.Graph installed. You need “AuditLog.Read.All” to access the login information for users and “User.Read.All” to retrieve the user and license information. The script is provided AS IS.
Check it out on Github: