Content reviewed: 12 October 2026

A user has Microsoft 365 E3, but was it assigned directly, through a group, or both? An operational audit needs assignment sources, their states and service settings. A product list cannot explain why a licence remains after removal from one group.

Separate provenance, state and consumption

licenseAssignmentStates identifies direct and group sources through assignedByGroup. A null value means a direct source. States include Active, ActiveWithError, Disabled and Error. lastUpdatedDateTime records the change of that state; it is not a complete change history.

Three different views
ViewQuestion answeredUnsupported conclusion
assignedLicensesWhich SKUs are assigned to the user?Complete provenance for every source
licenseAssignmentStatesWhere did the assignment come from, and what is its state?Every row consumes another purchased seat
subscribedSkusWhich products and aggregate consumption does the tenant report?An exact invoice or individual contractual rights

Our hypothetical example: Jane receives the same SKU directly and through two groups. That produces three source rows but one user–SKU pair. Row count therefore cannot determine seats or cost. subscribedSku exposes consumedUnits and prepaidUnits; commercial reconciliation also needs the actual subscriptions and commitments.

Permissions for a read-only export

This is an interactive delegated export. User.Read.All reads the requested user data; LicenseAssignment.Read.All reads tenant SKUs. We use GroupMember.Read.All for basic group properties and names. Licence write permissions are unnecessary for this workflow.

Assess administrator consent separately from the signed-in identity’s rights. For subscribedSkus, documented roles include Directory Readers and Global Reader. Verify reads against pilot accounts and groups first. Preserve a failed group read as an error; failure alone does not establish that the group was deleted.

Run the commands in order in one session

The first command installs the SDK; the others retrieve data and produce a CSV. Tenant reads do not change assignments. Installation writes a module to the user profile, and export writes a file to the working directory. Skip installation if already installed. Pilot this editorial report in a test environment; Microsoft’s official examples provide SDK-specific guidance.

Install-Module Microsoft.Graph -Scope CurrentUser

Connect-MgGraph -Scopes 'User.Read.All', 'GroupMember.Read.All', 'LicenseAssignment.Read.All' -NoWelcome; $ErrorActionPreference = 'Stop'; $stamp = (Get-Date).ToUniversalTime(); $capturedAt = $stamp.ToString('o')

$skuLookup = @{}; Get-MgSubscribedSku -All | ForEach-Object { $skuLookup[[string]$_.SkuId] = $_.SkuPartNumber }

$users = @(Get-MgUser -All -Property Id, DisplayName, UserPrincipalName, AccountEnabled, UsageLocation, LicenseAssignmentStates)

$sourceIds = @($users.LicenseAssignmentStates | Where-Object { $_.AssignedByGroup } | ForEach-Object { [string]$_.AssignedByGroup } | Sort-Object -Unique); $groups = @{}; $groupErrors = @{}

foreach ($id in $sourceIds) { try { $groups[$id] = (Get-MgGroup -GroupId $id -Property Id, DisplayName -ErrorAction Stop).DisplayName } catch { $groupErrors[$id] = $_.Exception.Message } }

$report = @(foreach ($user in $users) { $states = @($user.LicenseAssignmentStates | Where-Object { $_ }); foreach ($s in $states) { $sku = [string]$s.SkuId; $groupId = [string]$s.AssignedByGroup; $same = @($states | Where-Object { [string]$_.SkuId -eq $sku }); [pscustomobject]@{ CapturedAtUtc = $capturedAt; UserId = $user.Id; DisplayName = $user.DisplayName; UserPrincipalName = $user.UserPrincipalName; AccountEnabled = $user.AccountEnabled; UsageLocation = $user.UsageLocation; SkuId = $sku; SkuPartNumber = $skuLookup[$sku]; AssignmentType = $(if ($groupId) { 'Group' } else { 'Direct' }); SourceGroupId = $groupId; SourceGroupName = $(if ($groupId) { $groups[$groupId] } else { '' }); SourceResolution = $(if (-not $groupId) { 'NotApplicable' } elseif ($groups.ContainsKey($groupId)) { 'Resolved' } else { 'Unresolved' }); SourceReadError = $(if ($groupId) { $groupErrors[$groupId] } else { '' }); State = $s.State; Error = $s.Error; DisabledPlanIds = (@($s.DisabledPlans) -join ';'); LastUpdatedDateTime = $s.LastUpdatedDateTime; SourcesForSameSku = $same.Count; HasOverlappingSources = ($same.Count -gt 1); SameSkuSourceIds = (@($same | ForEach-Object { if ($_.AssignedByGroup) { [string]$_.AssignedByGroup } else { 'Direct' } }) -join ';') } } })

if ($report.Count -gt 0) { $report | Sort-Object UserId, SkuId, AssignmentType, SourceGroupId | Export-Csv -Path './m365-license-sources.csv' -NoTypeInformation -Encoding utf8 } else { Write-Warning 'No assignment-state rows returned; verify scope and requested properties before concluding that nobody is licensed.' }

Get-MgUser returns limited fields by default. Explicit -Property and -All are essential here: request assignment states and retrieve every page. Verify against a known licensed account first. Without that check, an empty output does not prove zero licences.

There is one row per user, SKU and source. Names are resolved only for unique source groups using Get group. Unrecognised SKUs retain their GUID; do not guess their commercial name. SourceReadError keeps the reason why a group read failed.

Prioritise errors separately from overlaps

Interpret the report
ResultNext check
Error or ActiveWithErrorInspect the specific failure and availability of the required service
HasOverlappingSources = TrueCompare sources and DisabledPlanIds for that user–SKU pair
SourceResolution = UnresolvedCheck the read error, permissions and group existence
AccountEnabled = FalseReview offboarding and retention; do not automatically remove licences
DisabledPlanIdsResolve IDs through ServicePlans and assess effective settings

CountViolation points towards seat capacity, DependencyViolation towards service dependencies and ProhibitedInUsageLocationViolation towards location. Select remediation from the actual record. Direct assignments may be valid exceptions, and overlapping groups may be deliberate. Record an owner and reason for each exception.

Confirm the destination before removing the source

Microsoft’s group licensing procedure is destination first: add the new group, confirm the licence has applied, then remove the original source. Membership alone does not prove processing is complete. With different SKUs or disabled plans, also verify the services needed; overlap can introduce its own conflicts.

Nested membership does not pass licences through parent groups. Set UsageLocation explicitly in multinational organisations; group assignment otherwise inherits the tenant’s location. A technical export does not establish eligibility for the feature. Microsoft’s overview lists P1 and selected Office 365 entitlements; verify actual coverage for the affected people.

Preserve a report that can be compared

Retain the raw export, UTC time, tenant, SDK version and query scope. Compare UserId, SkuId and SourceGroupId because names can change. Report source-row counts, unique user–SKU pairs and failing pairs separately. A failing user in two groups can otherwise distort the trend.

The export timestamp identifies the run, not an atomic snapshot across services. Changes can occur during retrieval, and Graph documents replication delays. Repeat checks after changes and confirm critical cases individually. Assignment auditing does not replace historical logs, each service’s provisioning state or a contractual licensing review.

Frequently asked questions

Do two groups providing the same SKU consume two seats?

Source count is not seat count. Assess the unique user and SKU, aggregate consumption and contractual terms. Overlap primarily flags configuration to review.

Why are assignment states empty?

Check explicit LicenseAssignmentStates in -Property, permissions, query scope and a known licensed account. Empty output alone cannot establish the conclusion.

Can direct licences be removed automatically?

Only after confirming the replacement source, required services and valid exceptions. This read-only export removes nothing.

Is LastUpdatedDateTime a change history?

No. It is the last change time of the current state. History requires the corresponding audit records and their available retention.

Entra P1, P2 and Governance: features and licence counts