Shine a light on your Microsoft 365 usage.
This tool provides a snapshot of license assignments and group memberships—perfect for cleanup, budgeting, and security reviews.
Description:
Quickly audit Microsoft 365 user licenses and group memberships to spot inconsistencies and optimize provisioning.
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All", "Directory.Read.All"
# Get all licensed users
$users = Get-MgUser -All | Where-Object { $_.AssignedLicenses }
foreach ($user in $users) {
$groups = Get-MgUserMemberOf -UserId $user.Id
[PSCustomObject]@{
DisplayName = $user.DisplayName
UserPrincipal = $user.UserPrincipalName
Licenses = ($user.AssignedLicenses | ForEach-Object { $_.SkuId }) -join ', '
Groups = ($groups | Where-Object { $_.'@odata.type' -eq '#microsoft.graph.group' } | ForEach-Object { $_.DisplayName }) -join ', '
}
}
Requires Microsoft Graph PowerShell SDK.
Replace SkuId
with readable license names by mapping GUIDs if needed.
Ideal for license audits and ensuring users belong to correct security or M365 groups.
© 2012–2025 Jet Mariano. All rights reserved.
For usage terms, please see the Legal Disclaimer.