Other toolsPowerShell

M365 – License Assignment Audit (PowerShell)

Review Microsoft 365 license assignments.

PowerShell
# Requires: AzureAD or Microsoft Graph
Connect-MgGraph -Scopes 'User.Read.All','Organization.Read.All' -NoWelcome
$users = Get-MgUser -All -Property Id,DisplayName,UserPrincipalName,AssignedLicenses
$report = foreach ($u in $users) { 
  [PSCustomObject]@{ User=$u.DisplayName; UPN=$u.UserPrincipalName; Licenses=($u.AssignedLicenses.Count) } 
}
$report | Export-Csv -NoTypeInformation -Path licenses.csv
  

From Joseph Nakhle's automation workbench.

More Other tools scripts