One of the recent cmdlets added to the UC Lobby Teams PowerShell module was Get-M365LicenseAssignment.
This cmdlet generates a report of all licenses assigned to users and how the user is getting that license assignment (Direct, Inherited).
The report will also include which services are enabled/disabled per license assigned to a user, for both direct and indirect assignments.
This new cmdlet requires that the MS Graph PowerShell module is installed and access to the following MS Graph scopes:
- Microsoft Graph Scopes:
- Directory.Read.All
- Or
- User.Read.All (Read Users)
- Group.Read.All (Read Groups) (only required if we want the Groups Display Name)
- Organization.Read.All (Subscribers SKUs)
To use this cmdlet, we need to install the UC Lobby Teams PowerShell module that is available in PowerShell Gallery.
Install-Module UCLobbyTeams
After installing we can import the modules and connect to MS Graph, then we can run Get-M365LicenseAssignment without any parameter, here is an example:
#Commercial Tenant:
Connect-MgGraph -Scopes "Directory.Read.All"
Get-M365LicenseAssignment
#US Gov (GCC-H) Tenant:
Connect-MgGraph -Scopes "Directory.Read.All" -Environment USGov
Get-M365LicenseAssignment
By default, the output folder will be the current user download folder, and with the following filename:
- M365LicenseAssigment_20231020-150906.csv
We can also specify an output folder with the parameter OutputPath.
Get-UcM365LicenseAssignment -OutputPath C:\UCLobby
Another useful switch is UseFriendlyNames, this will convert the SKU Part Number to Product Name and Service Plan Name to the correspondent Friendly Names
Example, the license will be converted from SPE_E5 to Microsoft 365 E5, and a service plan from TEAMS1 to Microsoft Teams.
Please note that UseFriendlyNames will try to download a csv file, the file will be stored in the user download folder or a folder specify with OutputPath parameter. For more information on csv file containing the license/service plan names please go to:
Product names and service plan identifiers for licensing
Get-UcM365LicenseAssignment -OutputPath C:\UCLobby -UseFriendlyNames
If the download fails, the UseFriendlyNames switch will be ignored.
The output is a CSV file that contains the following columns:
- UserPrincipalName
- LicenseAssigned – SKU Part Name or Product Name of the license assigned to the user.
- LicenseAssignment – If the license is Direct assigned or Inherited by a group.
- LicenseAssignmentGroup – Group name that is assigning the user a license.
- ServiceNames – Service Plans that exist in the tenant and if they are enabled/disabled on each license assignment.
Here is an example:
It is also possible to filter for a specific license using the SKU parameter:
Get-UcM365LicenseAssignment -SKU "SPE_E5"
Alternately, if we use the UseFriendlyNames switch we can specify the Product Name:
Get-UcM365LicenseAssignment -UseFriendlyNames -SKU "Microsoft 365 E5"
Get-UcM365LicenseAssignment -UseFriendlyNames -SKU "SPE_E5"
Special Thanks to Freydem Fernandez Lopez and Gal Naor for the assistance in implementing/testing this new cmdlet.
Source code available on GitHub – UCLobbyTeams
Get-M365LicenseAssignment is available UC Lobby Teams PowerShell module since version 0.4.0