Generate-M365LicenseAssignmentReport
3.0
This script connects to Microsoft 365 services and collects detailed information about license assignments across the tenant. It produces a formatted report showing which users have been assigned which licenses, including license details and assignment status. The report can be exported to various formats for analysis and compliance purposes.
Installation Options
Owners
Package Details
Author(s)
- Roy Klooster
Tags
RKSolutions Microsoft365 MicrosoftEntraID MicrosoftGraph
Functions
Export-Results New-HTMLReport Install-Requirements Connect-ToMgGraph Invoke-GraphRequestWithPaging Get-LicenseIdentifiers Send-EmailWithAttachment
Dependencies
This script has no dependencies.
Release Notes
Initial release - Comprehensive Microsoft 365 license assignment report with HTML output
v1.0 -2.3 - Test phase
v2.4 - Added function Test-MgGraphConnection to check for existing connections with the proper permissions
V2.5 - removed the need of "Microsoft.Graph.Beta.Identity.DirectoryManagement","Microsoft.Graph.Beta.Users", "Microsoft.Graph.Beta.Groups".
- Powershell 7 as requirements have been fixed + faster
v2.6 - Added Interactive, ClientSecret, Certificate, Identity and AccessToken parameters to support different authentication methods.
- Added support for sending the report via email with customizable subject and body text.
v2.7 - Added last successful sign-in information for each user.
v2.8 - Add extra check for Powershell version in the install-requirement function to install the most recent graph module version when Powershell 7
is used. If Powershell 5 is used. It will force the required 2.25.0 version because of compatibility
- fixed $lastSignIn variable to be used in the report
- fixed the filtering after adding a new column
v2.9 - Improved cross-platform compatibility for file paths and temporary directories.
- Added support for exporting the report to a custom path using the -ExportPath parameter.
v3.0 - AccessToken parameter changed to [SecureString] for compatibility with newer Microsoft.Graph (use e.g. -AccessToken (ConvertTo-SecureString "token" -AsPlainText -Force)).
- Connect-ToMgGraph: Interactive parameter set now supports -TenantId for GDAP/delegated access (connect to a specific tenant).
- Connect-MgGraph with AccessToken no longer passes -TenantId (not supported by current API).
- Cloud Licensing API: Integrated Microsoft's new Cloud Licensing API (beta/admin/cloudLicensing/allotments) for 35-40% faster performance.
- New data: Report now shows which licenses can be assigned to users, groups, or devices (AssignableTo).
- Enterprise-ready: Tested with thousands of users; automatic fallback to legacy endpoints ensures zero disruption.
- Fully backward compatible with existing deployments.
FileList
- Generate-M365LicenseAssignmentReport.nuspec
- Generate-M365LicenseAssignmentReport.ps1