Report · 2 tools

Licence assignment report by SKU

Summary

Shows how many licences you own, how many are assigned, and which users hold each SKU, with friendly names for the SKU part numbers. Run it before buying more licences or planning a migration.

Implementation

Choose your tool. Your choice is remembered on other samples.

Microsoft Graph PowerShell
Connect-MgGraph -Scopes Organization.Read.All, User.Read.All -NoWelcome
$skus = Get-MgSubscribedSku -All
$skus | Select-Object SkuPartNumber,
  @{ n = "Purchased"; e = { $_.PrepaidUnits.Enabled } },
  @{ n = "Assigned";  e = { $_.ConsumedUnits } },
  @{ n = "Free";      e = { $_.PrepaidUnits.Enabled - $_.ConsumedUnits } } | Format-Table

$skuName = @{}; $skus | ForEach-Object { $skuName[$_.SkuId] = $_.SkuPartNumber }
Get-MgUser -All -Property UserPrincipalName, AssignedLicenses |
  ForEach-Object { $u = $_; $u.AssignedLicenses | ForEach-Object {
    [pscustomobject]@{ User = $u.UserPrincipalName; Sku = $skuName[$_.SkuId] } } } |
  Export-Csv .\licence-assignments.csv -NoTypeInformation

Prerequisites

  • Graph scopes Organization.Read.All and User.Read.All

Output

Summary table per SKU, and a CSV of user and SKU pairs.

Contributors

AuthorRole
Priyanshu UpadhyaySolution Architect, Microsoft 365 and Azure
Disclaimer. These samples are provided as is, without warranty of any kind. Read and test every script in a non-production tenant before you run it, and run reports before any command that changes or deletes data.