Introduction
Every administrator knows the problem of licenses and their allocation. This is often a drama to get a good overview and to review this periodically. I have run into this problem several times and often you end up with ugly excel sheets with countless lines of information.
I have tried to come up with a solution. I wanted to have a responsive overview with easy filtering, viewing and color indication to notice peculiarities.
Requirements
- PowerShell 7.0 or higher – In my experience, PowerShell 5 does not handle the Microsoft Graph modules very nicely and I also noticed in my reporting that it showed erratic behavior. For example, friendly license names would not display correctly.
- Microsoft Graph PowerShell modules – The script requires several Microsoft Graph modules to function properly. The script will check for them and offer to install any missing modules.
Features
- Automatic License Discovery – Automatically retrieves the latest licenses from Microsoft, ensuring your report is always up-to-date.
- Comprehensive Assignment Overview – See all license assignments in one place with clear indications of direct vs. inherited assignments.
- Advanced Filtering – Filter by any attribute to quickly find the information you need.
- Multiple Export Options – Export to Excel, CSV, PDF, or print directly from the interface.
- Customizable View – Show/hide columns to focus on the information that matters to you.
- Light/Dark Mode Toggle
- Subscription Overview – Clear visualization of subscription status, counts, expiration dates, and availability.
- Inactive User Detection – Quickly identify licenses assigned to inactive users that could be reclaimed, potentially saving your organization thousands in unnecessary licensing costs
- Mail functionality:Â Reports can now be emailed using the same parameters: -SendMail, -Recipient, and -From.
How does it work?
This script is available in the Powershell Gallery. You can install it by the following line.
https://www.powershellgallery.com/packages/Generate-M365LicenseAssignmentReport/
Install-Script Generate-M365LicenseAssignmentReport -Force
Interactive Authentication
This is the simplest way to run the script. It will prompt you to log in with your Entra ID credentials.
Generate-M365LicenseAssignmentReport.ps1
Client Secret Authentication
This method is useful for automation scenarios. You’ll need to create an Entra ID application and grant it the required permissions.
Generate-M365LicenseAssignmentReport.ps1 -TenantId "your-tenant-id" -ClientId "your-client-id" -ClientSecret "your-client-secret"
Certificate Authentication
This method is also suitable for automation and is more secure than using a client secret. You’ll need to create an Entra ID application, upload a certificate, and provide the certificate thumbprint.
Generate-M365LicenseAssignmentReport.ps1 -TenantId "your-tenant-id" -ClientId "your-client-id" -CertificateThumbprint "your-certificateThumbprint"
Access Token Authentication
Accepts a pre-acquired access token for authentication. Useful when you’ve already obtained a token through another process or when integrating with existing authentication workflows. Provides flexibility but requires separate token management.
Generate-M365LicenseAssignmentReport.ps1 -Identity "ManagedIdentity"
Managed Identity Authentication
Uses Azure’s managed identities to authenticate without storing credentials. Ideal for scripts running in Azure environments (VMs, Functions, Automation). The most secure option as it eliminates credential management entirely.
Generate-M365LicenseAssignmentReport.ps1 -Accesstoken "AccessToken"
Email Functionality
This makes it easy to email reports automatically after generation.
Generate-M365LicenseAssignmentReport.ps1 -SendEmail -Recipient "Recipient" -From "Sender"
Conclusion
Hopefully this script will make it easier for you to get an overview of assigned licenses. It’s designed to simplify what has traditionally been a complex and time-consuming task for administrators.
If you encounter any bugs or have ideas for improvements, please let me know. I’m actively maintaining this tool and welcome your feedback to make it even better.
If you find this script helpful, feel free to reach out with questions or suggestions for improvements.