All scripts
Microsoft 365 317
Get-UnassignedLicenseReport
Reports how many licenses of each SKU are purchased versus assigned, so unused, paid for seats show up as a clear number instead of being buried in the billing portal.
Get-UnassignedLicenseReport.ps1
<#
.SYNOPSIS
Reports unassigned license counts by SKU.
.DESCRIPTION
Compares total purchased units against consumed units for every
subscribed SKU in the tenant, so unused, paid for licenses show up
as a clear number instead of being buried in the billing portal
across multiple product pages.
.EXAMPLE
.\Get-UnassignedLicenseReport.ps1
.NOTES
Requires Microsoft.Graph.Identity.DirectoryManagement with an active
Connect-MgGraph session.
.AUTHOR
Shehryar Hassan
#>
$skus = Get-MgSubscribedSku
$report = $skus | Select-Object SkuPartNumber,
@{N="Purchased";E={$_.PrepaidUnits.Enabled}},
@{N="Consumed";E={$_.ConsumedUnits}},
@{N="Unassigned";E={$_.PrepaidUnits.Enabled - $_.ConsumedUnits}}
$report | Sort-Object Unassigned -Descending | Format-Table -AutoSize
$wasted = $report | Where-Object Unassigned -gt 0
Write-Host "$($wasted.Count) SKU(s) with unassigned licenses" -ForegroundColor Cyan
Read it before you run it, and test in a safe tenant first.